[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: noisy gnulib-tool on IRIX

From: Ralf Wildenhues
Subject: Re: noisy gnulib-tool on IRIX
Date: Wed, 8 Sep 2010 07:38:06 +0200
User-agent: Mutt/1.5.20 (2010-04-22)

* Eric Blake wrote on Wed, Sep 08, 2010 at 03:12:48AM CEST:
> $ /bin/sh -c 'alias 2>/dev/null'
> alias: Not found
> $ /bin/sh -c '(alias) 2>/dev/null'
> $ /bin/sh -c 'exec 3>&2; exec 2>/dev/null; unalias echo; exec 2>&3;
> exec 3>&-'
> $
> the indirect redirection of stderr prior to attempting the unfound
> command does indeed work to silence the message, without costing a
> subshell (hmm, maybe autoconf should use that trick to reduce
> forking at m4sh startup).

  exec 3>&2 2>/dev/null; command; exec 2>&3 3>&-

has the advantage of not forking, the disadvantage of using another file
descriptor (which we should probably disallow the user from passing in).

With modern shells, it should work just as well to
  { command; } 2>/dev/null

except of course, really old shells will fork a subshell in order to
execute redirected compound commands, so unless we have some indication
that this was fixed before some other feature we rely on was fixed  ;-)
we might need a test for that.

I expect that some shells try to optimize (command) 2>/dev/null by not
always executing command in a subshell (that would explain some of the
bugs old dash had), but I don't know how common that is.  builtin vs.
external command are a potential difference, too, also for old shell


reply via email to

[Prev in Thread] Current Thread [Next in Thread]