git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: [PATCH 3/4] clone: bsd shell portability fix
Date: Tue, 13 May 2008 04:45:56 -0400	[thread overview]
Message-ID: <20080513084556.GC23799@sigill.intra.peff.net> (raw)
In-Reply-To: <20080513084338.GA23729@sigill.intra.peff.net>

When using /bin/sh from FreeBSD 6.1, the value of $? is lost
when calling a function inside the 'trap' action. This
resulted in clone erroneously indicating success when it
should have reported failure.

As a workaround, we save the value of $? before calling any
functions.

Signed-off-by: Jeff King <peff@peff.net>
---
 git-clone.sh |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/git-clone.sh b/git-clone.sh
index 9d88d1c..547228e 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -240,7 +240,6 @@ die "working tree '$GIT_WORK_TREE' already exists."
 D=
 W=
 cleanup() {
-	err=$?
 	test -z "$D" && rm -rf "$dir"
 	test -z "$W" && test -n "$GIT_WORK_TREE" && rm -rf "$GIT_WORK_TREE"
 	cd ..
@@ -248,7 +247,7 @@ cleanup() {
 	test -n "$W" && rm -rf "$W"
 	exit $err
 }
-trap cleanup 0
+trap 'err=$?; cleanup' 0
 mkdir -p "$dir" && D=$(cd "$dir" && pwd) || usage
 test -n "$GIT_WORK_TREE" && mkdir -p "$GIT_WORK_TREE" &&
 W=$(cd "$GIT_WORK_TREE" && pwd) && GIT_WORK_TREE="$W" && export GIT_WORK_TREE
-- 
1.5.5.1.296.gf618c

  parent reply	other threads:[~2008-05-13  8:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-13  8:43 [PATCH 0/4] freebsd portability fixes Jeff King
2008-05-13  8:44 ` [PATCH 1/4] fix bsd shell negation Jeff King
2008-05-14  2:27   ` Junio C Hamano
2008-05-14  4:01     ` Jeff King
2008-05-13  8:45 ` [PATCH 2/4] t5000: tar portability fix Jeff King
2008-05-13  8:45 ` Jeff King [this message]
2008-05-13  8:46 ` [PATCH 4/4] filter-branch: fix variable export logic Jeff King
2008-05-14  4:18   ` Junio C Hamano
2008-05-14  4:57     ` Jeff King
2008-05-14  9:33       ` Paolo Bonzini
2008-05-13  9:04 ` [PATCH 0/4] freebsd portability fixes Jeff King
2008-05-13 20:39   ` Alex Riesen
2008-05-13 20:44     ` Alex Riesen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080513084556.GC23799@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).