@matheusbsbs / matheus-bagliano / commits / 3fa7c3da37
Fork 0

work around an obnoxious bash "safety feature" on OpenBSD

Bash (4.0.24) on OpenBSD 4.6 refuses to run this snippet: $ cat gomi.sh #!/bin/sh one="/var/tmp/1 1" rm -f /var/tmp/1 "/var/tmp/1 1" echo hello >$one $ sh gomi.sh; ls /var/tmp/1* /var/tmp/1 1 $ bash gomi.sh; ls /var/tmp/1* gomi.sh: line 4: $one: ambiguous redirect ls: /var/tmp/1*: No such file or directory Every competent shell programmer knows that a <$word in redirection is not subject to field splitting (POSIX.1 "2.7 Redirection" explicitly lists the kind of expansion performed: "... the word that follows the redirection operator shall be subjected to ...", and "Field Splitting" is not among them). Some clueless folks apparently decided that users need to be protected in the name of "security", however. Output from "git grep -e '> *\$' -- '*.sh'" indicates that rebase-i suffers from this bogus "safety". Work it around by surrounding the variable reference with a dq pair. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Jan 26, 2010 at 16:29 UTC 3fa7c3da379bb47a0e7a52ffc13cb366add880a2
1 file changed +3 -3
git-rebase--interactive.sh
+3 -3
@@ -378,7 +378,7 @@ update_squash_messages () {
378 sed -e 1d -e '2,/^./{
379 /^$/d
380 }' <"$SQUASH_MSG".bak
381 - } >$SQUASH_MSG
381 + } >"$SQUASH_MSG"
382 else
383 commit_message HEAD > "$FIXUP_MSG" || die "Cannot write $FIXUP_MSG"
384 COUNT=2
@@ -387,7 +387,7 @@ update_squash_messages () {
387 echo "# The first commit's message is:"
388 echo
389 cat "$FIXUP_MSG"
390 - } >$SQUASH_MSG
390 + } >"$SQUASH_MSG"
391 fi
392 case $1 in
393 squash)
@@ -403,7 +403,7 @@ update_squash_messages () {
403 echo
404 commit_message $2 | sed -e 's/^/# /'
405 ;;
406 - esac >>$SQUASH_MSG
406 + esac >>"$SQUASH_MSG"
407 }
408
409 peek_next_command () {