{"thread":{"id":"22404","subject":"[PATCH] work around an obnoxious bash \"safety feature\" on OpenBSD","startedAt":"2010-01-27T00:29:30Z","lastAt":"2010-01-27T03:01:32Z","messageCount":3,"participants":["Junio C Hamano","Jeff Epler"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"132731","messageId":"7veilcxudx.fsf@alter.siamese.dyndns.org","threadId":"22404","inReplyTo":null,"subject":"[PATCH] work around an obnoxious bash \"safety feature\" on OpenBSD","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-01-27T00:29:30Z","receivedAt":"2010-01-27T00:29:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Bash (4.0.24) on OpenBSD 4.6 refuses to run this snippet:\n\n    $ cat gomi.sh\n    #!/bin/sh\n    one=\"/var/tmp/1 1\"\n    rm -f /var/tmp/1 \"/var/tmp/1 1\"\n    echo hello >$one\n    $ sh gomi.sh; ls /var/tmp/1*\n    /var/tmp/1 1\n    $ bash gomi.sh; ls /var/tmp/1*\n    gomi.sh: line 4: $one: ambiguous redirect\n    ls: /var/tmp/1*: No such file or directory\n\nEvery competent shell programmer knows that a <$word in redirection is not\nsubject to field splitting (POSIX.1 \"2.7 Redirection\" explicitly lists the\nkind of expansion performed: \"... the word that follows the redirection\noperator shall be subjected to ...\", and \"Field Splitting\" is not among\nthem).\n\nSome clueless folks apparently decided that users need to be protected in\nthe name of \"security\", however.\n\nOutput from \"git grep -e '> *\\$' -- '*.sh'\" indicates that rebase-i\nsuffers from this bogus \"safety\".  Work it around by surrounding the\nvariable reference with a dq pair.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n * I don't regularly run OpenBSD and build test on the platform only\n   occasionally.  People who _do_ care about the platform perhaps need to\n   run the testsuite to find and help fixing other possible issues.\n\n   You will trigger this the path to your git work tree has whitespace\n   in it, e.g. t3404.\n\n git-rebase--interactive.sh |    9 +++++----\n 1 files changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 19a608c..cecaa1d 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -368,7 +368,8 @@ nth_string () {\n }\n \n update_squash_messages () {\n-\tif test -f \"$SQUASH_MSG\"; then\n+\tif test -f \"$SQUASH_MSG\"\n+\tthen\n \t\tmv \"$SQUASH_MSG\" \"$SQUASH_MSG\".bak || exit\n \t\tCOUNT=$(($(sed -n \\\n \t\t\t-e \"1s/^# This is a combination of \\(.*\\) commits\\./\\1/p\" \\\n@@ -378,7 +379,7 @@ update_squash_messages () {\n \t\t\tsed -e 1d -e '2,/^./{\n \t\t\t\t/^$/d\n \t\t\t}' <\"$SQUASH_MSG\".bak\n-\t\t} >$SQUASH_MSG\n+\t\t} >\"$SQUASH_MSG\"\n \telse\n \t\tcommit_message HEAD > \"$FIXUP_MSG\" || die \"Cannot write $FIXUP_MSG\"\n \t\tCOUNT=2\n@@ -387,7 +388,7 @@ update_squash_messages () {\n \t\t\techo \"# The first commit's message is:\"\n \t\t\techo\n \t\t\tcat \"$FIXUP_MSG\"\n-\t\t} >$SQUASH_MSG\n+\t\t} >\"$SQUASH_MSG\"\n \tfi\n \tcase $1 in\n \tsquash)\n@@ -403,7 +404,7 @@ update_squash_messages () {\n \t\techo\n \t\tcommit_message $2 | sed -e 's/^/#\t/'\n \t\t;;\n-\tesac >>$SQUASH_MSG\n+\tesac >>\"$SQUASH_MSG\"\n }\n \n peek_next_command () {\n\n\n\n    \n"},{"id":"132742","messageId":"20100127024148.GA18826@unpythonic.net","threadId":"22404","inReplyTo":"7veilcxudx.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] work around an obnoxious bash \"safety feature\" on OpenBSD","fromName":"Jeff Epler","fromEmail":"jepler@unpythonic.net","sentAt":"2010-01-27T02:41:48Z","receivedAt":"2010-01-27T02:41:48Z","isPatch":true,"sender":{"key":"jepler@unpythonic.net","avatar":"https://avatars.githubusercontent.com/u/1517291?v=4"},"body":"On Tue, Jan 26, 2010 at 04:29:30PM -0800, Junio C Hamano wrote:\n>  update_squash_messages () {\n> -\tif test -f \"$SQUASH_MSG\"; then\n> +\tif test -f \"$SQUASH_MSG\"\n> +\tthen\n\nI don't think this belongs here.\n\nJeff\n"},{"id":"132744","messageId":"7vhbq8w8s3.fsf@alter.siamese.dyndns.org","threadId":"22404","inReplyTo":"20100127024148.GA18826@unpythonic.net","subject":"Re: [PATCH] work around an obnoxious bash \"safety feature\" on OpenBSD","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-01-27T03:01:32Z","receivedAt":"2010-01-27T03:01:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff Epler <jepler@unpythonic.net> writes:\n\n> On Tue, Jan 26, 2010 at 04:29:30PM -0800, Junio C Hamano wrote:\n>>  update_squash_messages () {\n>> -\tif test -f \"$SQUASH_MSG\"; then\n>> +\tif test -f \"$SQUASH_MSG\"\n>> +\tthen\n>\n> I don't think this belongs here.\n>\n> Jeff\n\nYeah, it is a general improvement in the vicinity.\n"}]}