bug-gnulib
[Top][All Lists]
Advanced

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

Re: noisy gnulib-tool on IRIX


From: Bruno Haible
Subject: Re: noisy gnulib-tool on IRIX
Date: Wed, 8 Sep 2010 10:44:18 +0200
User-agent: KMail/1.9.9

Hi Eric,

> 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.

Ah, I didn't think of this trick. But as you noticed, the trick I've found
is more efficient, so I'll use it.

> $ /bin/sh -c 'alias 2>/dev/null'
> alias: Not found
> $ /bin/sh -c 'exec 3>&2; exec 2>/dev/null; unalias echo; exec 2>&3; exec 3>&-'

Good, it works. So I'm applying the patch below.

> 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).

Well, the code is clear: We know we have to handle ksh without re-execing,
and in ksh the solution is to use an alias to a shell function that invokes
'cat'. If we're not in ksh, then the code notices it by the fact that the
'alias' command did not work, and tries to re-exec. Which code path does it
end up taking on IRIX (i.e. what's the result when you add a 'set -x'
command at the top of gnulib-tool)?


2010-09-08  Bruno Haible  <address@hidden>

        gnulib-tool: Avoid stderr output on IRIX related to 'alias', 'unalias'.
        * gnulib-tool: Use stderr redirection around the 'alias' and 'unalias'
        commands, because some shells ignore redirections when there is an
        error in the command lookup.
        Reported by Eric Blake.

--- gnulib-tool.orig    Wed Sep  8 10:24:19 2010
+++ gnulib-tool Wed Sep  8 10:12:02 2010
@@ -842,14 +842,22 @@
 $*
 EOF
 }
-alias echo=bsd_echo 2>/dev/null
+exec 3>&2
+exec 2>/dev/null
+alias echo=bsd_echo
+exec 2>&3
+exec 3>&-
 fi
 if test -z "$have_echo" \
    && echo '\t' | grep t > /dev/null; then
   have_echo=yes
 fi
 if test -z "$have_echo"; then
-  unalias echo 2>/dev/null
+  exec 3>&2
+  exec 2>/dev/null
+  unalias echo
+  exec 2>&3
+  exec 3>&-
 fi
 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
 if test -z "$have_echo" \



reply via email to

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