On Fri, Feb 21, 2020 at 09:34:59PM +0100, Christian Weisgerber wrote:
> Marc Espie:
>
> > --- bin/portbump 27 Jun 2018 16:20:08 -0000 1.22
> > +++ bin/portbump 19 Feb 2020 15:52:58 -0000
> > @@ -98,6 +98,18 @@ my @_REV_NEIGHBORS_WEAK = qw(
> > );
> > my $_rev_neighbors_plain_all = join('|', @_REV_NEIGHBORS,
> > @_REV_NEIGHBORS_WEAK);
> >
> > +sub run_make
> > +{
> > + my $dir = shift;
> > + my $pid = open(my $pipe, "-|");
> > + if ($pid == 0) {
> > + $ENV{SUBDIR}=$dir;
> > + exec {'make'} ('make', @_);
> > + exit(1);
> > + }
> > + return $pipe;
> > +}
> > +
> > sub new {
> > my ($class, $dir, $tweak_wantlib, $lib_depends_tgt) = @_;
> > die "lib depends target specified without WANTLIB tweaking"
> > @@ -117,8 +129,8 @@ sub new {
> > # Get actual information about subpackages (including their
> > # REVISIONs) and shared libraries.
> > #
> > - open (my $dumpvars, '-|', "make", "SUBDIR=$dir", "dump-vars") or
> > - die "cannot run make dump-vars: $!";
> > +
> > + my $dumpvars = run_make($dir, 'dump-vars');
>
> Hmm, no error handling?
Right... How do you handle errors from a pipe ?
Not when you open it, anyway.
All the open(... "-|", ...) or die ...
are bogus in that file. They will only happen if fork fails (fat chance)
or you run out of file descriptors. The proper way to handle the error would
be at the close point.
Actually, I will probably do a "better" function for that program, because
the pipes have fairly small output, and so encapsulating the whole pipe run
and returning an array of lines will be just as efficient.
> > --- bin/portcheck 12 Nov 2019 06:01:04 -0000 1.130
> > +++ bin/portcheck 19 Feb 2020 15:52:58 -0000
> > @@ -1481,7 +1481,7 @@ check_lib_depends() {
> > # TODO cache print-plist-libs output?
> > cd -- /usr/ports # XXX "$portsdir" fails for openbsd-wip and like
> > unset FLAVOR SUBPACKAGE
> > - make "${make_args[@]}" SUBDIR="${pure_lib_deps[*]}" \
> > + SUBDIR="${pure_lib_deps[*]}" make "${make_args[@]}"
>
> Missing line continuation.
Gotcha