[pacman-dev] [PATCHv3 6/7] pacsearch: pattern arguments work as for pacman
Pierre Neidhardt
ambrevar at gmail.com
Mon Feb 10 12:46:50 EST 2014
On 14-02-10 12:35:39, Andrew Gregory wrote:
> On 02/10/14 at 06:27pm, Pierre Neidhardt wrote:
> > On 14-02-10 12:15:03, Andrew Gregory wrote:
> > > On 02/10/14 at 05:26pm, Pierre Neidhardt wrote:
> > > > On 14-02-10 11:09:25, Andrew Gregory wrote:
> > > > > On 02/09/14 at 07:41pm, Pierre Neidhardt wrote:
> > > > > > +open (my $syncout, '-|', 'pacman', '-Ss', @ARGV) or exit;
> > > > >
> > > > > If we can't run pacman we need to print an error message and exit
> > > > > non-zero.
> > > >
> > > > 'open' already prints an error message. Writing
> > >
> > > So perl prints its own warning on open() failures only for pipes,
> > > breaking a common idiom... brilliant. I'm tempted to disable that
> > > warning and print our own to get rid of the script name and line
> > > number, but given how unlikely it is to happen, it may not be worth
> > > it. Any thoughts? We still need to exit non-zero either way.
> > >
> > > > +open (my $syncout, '-|', 'pacman', '-Ss', @ARGV) or die "pacman not found: $!";
> >
> > I was quite surprised as well, considering that the above line comes directly
> > from the official documentation...
> >
> > How do you disable error output from open?
>
> "no warnings 'io';" should do it. See perldoc perllexwarn
Alright. We have the choice between
* using 'exit' and rely on perl's behaviour printing its own warnings;
* disabling warning for the 'open' line only. More reliable, but more code and
looks hackish.
Not beautiful either way, but this is perl. I suggest we stick to the lightest
solution with a simple exit call.
--
Pierre Neidhardt
He's dead, Jim.
More information about the pacman-dev
mailing list