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: Tue, 04 Jan 2011 09:54:34 +0100

Bruce Korb wrote:
> On 01/03/11 16:13, Eric Blake wrote:
>> $ /bin/sh -c 'v=`nonesuch` 2>/dev/null'
>> nonesuch: not found
>> $ /bin/sh -c 'v=`(nonesuch) 2>/dev/null`'
>> $
>
> Just for grins, how about trying:
>
> /bin/sh -c 'v=`exec 2>/dev/null;nonesuch`'
>
> I think it works for me on a Sun box:
>
>  sunfall_bkorb $ /bin/sh -c '`nonesuch`' 2>/dev/null
>  sunfall_bkorb $ /bin/sh -c '`nonesuch` 2>/dev/null'
> /bin/sh: nonesuch: not found
>  sunfall_bkorb $ /bin/sh -c '`exec  2>/dev/null;nonesuch`'

Good idea.  Avoiding an unnecessary sub-shell is always welcome.
I'll wait for your "ok".

>From fa6be5b2b297b569d890535b0126054789f8a6fb Mon Sep 17 00:00:00 2001
From: Bruce Korb <address@hidden>
Date: Tue, 4 Jan 2011 09:47:49 +0100
Subject: [PATCH] git-version-gen: avoid a sub-shell

* build-aux/git-version-gen: Redirect stderr in `...` via
"exec 2>...", rather than via an added sub-shell.
---
 ChangeLog                 |    6 ++++++
 build-aux/git-version-gen |    4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index bb3d9cf..b8456de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-01-04  Bruce Korb  <address@hidden>
+
+       git-version-gen: avoid a sub-shell
+       * build-aux/git-version-gen: Redirect stderr in `...` via
+       "exec 2>...", rather than via an added sub-shell.
+
 2011-01-03  Ben Pfaff  <address@hidden>

        git-version-gen: use (...) rather than sh -c '...'
diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen
index 694ba46..6f8b160 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.20; # UTC
+scriptversion=2011-01-04.08; # 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=`(git diff-index --name-only HEAD) 2>/dev/null` || dirty=
+dirty=`exec 2>/dev/null; git diff-index --name-only HEAD` || 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]