[adding bug-autoconf for a potential optimization]
On 09/07/2010 06:14 PM, Bruno Haible wrote:
Eric Blake wrote:
$ ./gnulib-tool --help 2>&1 | head -n3
alias: Not found
unalias: Not found
Usage: gnulib-tool --list
What happens if you replace the command
unalias echo 2>/dev/null
The point is that IRIX /bin/sh lacks alias and unalias, so it treats it
like any other command. And in general, it does command lookup prior to
redirections, so directly redirecting to stderr does not squelch
messages for missing commands; hence the common idiom of first checking
if alias/unalias exist using a subshell check, and if so then using them
in the parent shell.
What I wasn't sure about is why you were trying to set up an alias in
the first place, nor how you plan on working around echo(1) issues
without the use of alias(1).
Meanwhile, in answer to your question,
$ /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).
--
Eric Blake ebl...@redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org