From: Jonathan Nieder <jrnieder@gmail.com>
To: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
Cc: Ben Walton <bwalton@artsci.utoronto.ca>,
git@vger.kernel.org, gitster@pobox.com, Jeff King <peff@peff.net>
Subject: Re: [PATCH] t0300-credentials: Word around a solaris /bin/sh bug
Date: Thu, 2 Feb 2012 15:11:46 -0600 [thread overview]
Message-ID: <20120202211146.GC19520@burratino> (raw)
In-Reply-To: <vpq62fp3r15.fsf@bauges.imag.fr>
Matthieu Moy wrote:
> Jonathan Nieder <jrnieder@gmail.com> writes:
>> (
>> IFS==
>> while read key value
>> do
>> ...
>> done
>> )
[...]
> I don't think so since the "..." contains
>
> eval "$key=$value"
Oh, whoops. Thanks for noticing.
Here's an updated patch, for amusement value. No functional change
intended. I don't think it's actually worth applying unless people
actively working on this file find the result easier to work with.
-- >8 --
Subject: t0300 (credentials): shell scripting style cleanups
As Ben noticed, the helper used by this test script assigns a
temporary value to IFS while calling the "read" builtin, which in
ancient shells causes the value to leak into the environment and
affect later code in the same script. Explicitly save and restore IFS
to avoid rekindling old memories.
While at it, put the "do" associated to a "while" statement on its own
line to match the house style and define helper scripts in the test
data section above all test assertions so the "setup" test itself is
less cluttered and we can worry a little less about quoting issues.
Inspired-by: Ben Walton <bwalton@artsci.utoronto.ca>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
t/t0300-credentials.sh | 36 ++++++++++++++++++++----------------
1 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/t/t0300-credentials.sh b/t/t0300-credentials.sh
index edf65478..780d5dcb 100755
--- a/t/t0300-credentials.sh
+++ b/t/t0300-credentials.sh
@@ -4,33 +4,37 @@ test_description='basic credential helper tests'
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-credential.sh
-test_expect_success 'setup helper scripts' '
- cat >dump <<-\EOF &&
+cat >dump <<-\EOF
whoami=`echo $0 | sed s/.*git-credential-//`
echo >&2 "$whoami: $*"
- while IFS== read key value; do
+ save_IFS=$IFS
+ IFS==
+ while read key value
+ do
echo >&2 "$whoami: $key=$value"
eval "$key=$value"
done
- EOF
+ IFS=$save_IFS
+EOF
- cat >git-credential-useless <<-EOF &&
+cat >git-credential-useless <<-EOF
#!$SHELL_PATH
. ./dump
exit 0
- EOF
+EOF
+
+cat >git-credential-verbatim <<-EOF
+ #!$SHELL_PATH
+ user=\$1; shift
+ pass=\$1; shift
+ . ./dump
+ test -z "\$user" || echo username=\$user
+ test -z "\$pass" || echo password=\$pass
+EOF
+
+test_expect_success setup '
chmod +x git-credential-useless &&
-
- echo "#!$SHELL_PATH" >git-credential-verbatim &&
- cat >>git-credential-verbatim <<-\EOF &&
- user=$1; shift
- pass=$1; shift
- . ./dump
- test -z "$user" || echo username=$user
- test -z "$pass" || echo password=$pass
- EOF
chmod +x git-credential-verbatim &&
-
PATH="$PWD:$PATH"
'
--
1.7.9
prev parent reply other threads:[~2012-02-02 21:12 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-02 19:32 [PATCH] t0300-credentials: Word around a solaris /bin/sh bug Ben Walton
2012-02-02 19:44 ` Frans Klaver
2012-02-02 19:48 ` Ben Walton
2012-02-02 20:02 ` Jeff King
2012-02-03 1:02 ` Junio C Hamano
2012-02-03 12:06 ` Jeff King
2012-02-03 13:45 ` Ben Walton
2012-02-03 20:32 ` Junio C Hamano
2012-02-03 21:26 ` Jeff King
2012-02-03 21:50 ` Junio C Hamano
2012-02-03 21:55 ` Jeff King
2012-02-03 22:00 ` Ben Walton
2012-02-03 22:45 ` Junio C Hamano
2012-02-03 23:27 ` Jeff King
2012-02-04 6:27 ` Jeff King
2012-02-04 6:29 ` [PATCH 1/2] tests: add write_script helper function Jeff King
2012-02-04 6:30 ` [PATCH 2/2] t0300: use write_script helper Jeff King
2012-02-04 6:58 ` Junio C Hamano
2012-02-04 7:00 ` Jeff King
2012-02-02 20:16 ` [PATCH] t0300-credentials: Word around a solaris /bin/sh bug Jonathan Nieder
2012-02-02 20:43 ` Matthieu Moy
2012-02-02 21:11 ` Jonathan Nieder [this message]
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=20120202211146.GC19520@burratino \
--to=jrnieder@gmail.com \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=bwalton@artsci.utoronto.ca \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/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).