{"thread":{"id":"29818","subject":"[PATCH] t0300: work around bug in dash 0.5.6","startedAt":"2012-03-03T00:37:35Z","lastAt":"2012-03-03T00:37:35Z","messageCount":1,"participants":["Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"185956","messageId":"20120303003735.GA804@sigill.intra.peff.net","threadId":"29818","inReplyTo":"93904081120af9a646b8bda96aa2da8e85cc063d.1330700524.git.git@drmicha.warpmail.net","subject":"[PATCH] t0300: work around bug in dash 0.5.6","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-03-03T00:37:35Z","receivedAt":"2012-03-03T00:37:35Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"From: Michael J Gruber <git@drmicha.warpmail.net>\n\nThe construct 'while IFS== read' makes dash 0.5.6 execute\nread without changing IFS, which results in test breakages\nall over the place in t0300.  Neither dash 0.5.5.1 and older\nnor dash 0.5.7 and newer are affected: The problem was\nintroduded resp. fixed by the commits\n\n  55c46b7 ([BUILTIN] Honor tab as IFS whitespace when\n           splitting fields in readcmd, 2009-08-11)\n\n  1d806ac ([VAR] Do not poplocalvars prematurely on regular\n           utilities, 2010-05-27)\n\nin http://git.kernel.org/?p=utils/dash/dash.git\n\nPutting 'IFS==' before that line makes all versions of dash\nwork.\n\nThis looks like a dash bug, not a misinterpretation of the\nstandard. However, it's worth working around for two\nreasons. One, this version of dash was released in Fedora\n14-16, so the bug is found in the wild. And two, at least\none other shell, Solaris /bin/sh, choked on this by\npersisting IFS after the read invocation. That is not a\nshell we usually care about, and I think this use of IFS is\nacceptable by POSIX (which allows other behavior near\n\"special builtins\", but \"read\" is not one of those). But it\nseems that this may be a subtle, not-well-tested case for\nsome shells. Given that the workaround is so simple, it's\nworth just being defensive.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\nSigned-off-by: Jeff King <peff@peff.net>\n---\nMichael and I discussed this off-list. The patch is his, but I've\nrewritten much of the commit message to incorporate the recent thread\nover this exact same bit of code on Solaris:\n\n  http://thread.gmane.org/gmane.comp.version-control.git/189680\n\nThis patch is basically the same as Ben Walton's from that thread, but\nwe ended up creating and using the write_script function to avoid using\nSolaris /bin/sh at all.\n\n t/t0300-credentials.sh |    5 ++++-\n 1 file changed, 4 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t0300-credentials.sh b/t/t0300-credentials.sh\nindex 8621ab0..20e28e3 100755\n--- a/t/t0300-credentials.sh\n+++ b/t/t0300-credentials.sh\n@@ -8,10 +8,13 @@ test_expect_success 'setup helper scripts' '\n \tcat >dump <<-\\EOF &&\n \twhoami=`echo $0 | sed s/.*git-credential-//`\n \techo >&2 \"$whoami: $*\"\n-\twhile IFS== read key value; do\n+\tOIFS=$IFS\n+\tIFS==\n+\twhile read key value; do\n \t\techo >&2 \"$whoami: $key=$value\"\n \t\teval \"$key=$value\"\n \tdone\n+\tIFS=$OIFS\n \tEOF\n \n \twrite_script git-credential-useless <<-\\EOF &&\n-- \n1.7.6.6.7.g65e2\n"}]}