bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] git-version-gen: include command name in one more diagnostic


From: Ralf Wildenhues
Subject: Re: [PATCH] git-version-gen: include command name in one more diagnostic
Date: Mon, 3 Jan 2011 21:05:02 +0100
User-agent: Mutt/1.5.20 (2010-08-04)

Hello Ben, Jim,

* Ben Pfaff wrote on Mon, Jan 03, 2011 at 08:54:19PM CET:
> Jim Meyering <address@hidden> writes:
> 
> > Bruce Korb wrote:
> >> Does that "git diff-index" really need to be run in a separate
> >> shell invocation?
> >>> dirty=`sh -c 'git diff-index --name-only HEAD' 2>/dev/null` || dirty=
> >
> > Yes.  As I recall, that was required in order to ensure that even when
> > the shell fails to find a "git" program, the stderr output
> > is redirected.
> 
> What the Autoconf manual says about this is:
> 
>        On the other hand, some shells, such as Solaris or FreeBSD
>     `/bin/sh', warn about missing programs before performing redirections.
>     Therefore, to silently check whether a program exists, it is necessary
>     to perform redirections on a subshell:
> 
>          $ /bin/sh -c 'nosuch 2>/dev/null'
>          nosuch: not found
>          $ /bin/sh -c '(nosuch) 2>/dev/null'
>          $ bash -c 'nosuch 2>/dev/null'
> 
> I always understood the use of "sh -c" in these examples as a
> device to show which shell was being invoked, not to advise
> actually using "sh -c".  Rather, I thought that the advice was to
> put the invocation in a subshell, as "(nosuch) 2>/dev/null".

You are both right, on all accounts.  Whether you use a sh -c instance
and redirect stderr outside the argument to -c, or use a subshell and
redirect stderr outside the subshell, both avoids the escaping of
errors.

Cheers,
Ralf



reply via email to

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