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: Ben Pfaff
Subject: Re: [PATCH] git-version-gen: include command name in one more diagnostic
Date: Mon, 03 Jan 2011 11:54:19 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

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".
-- 
Only wimps use tape backup: _real_ men just upload their important stuff
on ftp, and let the rest of the world mirror it ;)
        -- Linus Torvalds




reply via email to

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