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: Jim Meyering
Subject: Re: [PATCH] git-version-gen: include command name in one more diagnostic
Date: Mon, 03 Jan 2011 21:07:05 +0100

Ben Pfaff wrote:

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

Hi Ben,

Good idea.
This has your name on it, so I'll wait for an "ok" before pushing:

>From a2e8447d6b8abe23504f4f2d4757a60a2e8bee54 Mon Sep 17 00:00:00 2001
From: Ben Pfaff <address@hidden>
Date: Mon, 3 Jan 2011 21:05:04 +0100
Subject: [PATCH] git-version-gen: use (...) rather than sh -c '...'

* build-aux/git-version-gen: Rather than hard-coding a shell's name
with "sh -c '...'", just use "(...)".  Less syntax is better, too.
---
 ChangeLog                 |    6 ++++++
 build-aux/git-version-gen |    4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 97e911b..bb3d9cf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-01-03  Ben Pfaff  <address@hidden>
+
+       git-version-gen: use (...) rather than sh -c '...'
+       * build-aux/git-version-gen: Rather than hard-coding a shell's name
+       with "sh -c '...'", just use "(...)".  Less syntax is better, too.
+
 2011-01-03  Jim Meyering  <address@hidden>

        git-version-gen: convert leading TABs to spaces
diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen
index f116ba1..694ba46 100755
--- a/build-aux/git-version-gen
+++ b/build-aux/git-version-gen
@@ -1,6 +1,6 @@
 #!/bin/sh
 # Print a version string.
-scriptversion=2011-01-03.19; # UTC
+scriptversion=2011-01-03.20; # UTC

 # Copyright (C) 2007-2011 Free Software Foundation, Inc.
 #
@@ -143,7 +143,7 @@ v=`echo "$v" |sed 's/^v//'`
 # Don't declare a version "dirty" merely because a time stamp has changed.
 git update-index --refresh > /dev/null 2>&1

-dirty=`sh -c 'git diff-index --name-only HEAD' 2>/dev/null` || dirty=
+dirty=`(git diff-index --name-only HEAD) 2>/dev/null` || dirty=
 case "$dirty" in
     '') ;;
     *) # Append the suffix only if there isn't one already.
--
1.7.3.4



reply via email to

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