From 2bea74df35893ffea60286b114aa0198aa0ae82f Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Sun, 3 Mar 2019 20:56:17 -0500 Subject: [PATCH] Work around ancient shells where >$3 does not implicitly quote $3. Also add an entry in shelltest.od to reject any shell exhibiting that bug. Reported-by: Wayne Scott --- docs/cookbook/c/hello world.list.od | 4 ++-- t/shelltest.od | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/cookbook/c/hello world.list.od b/docs/cookbook/c/hello world.list.od index 6f5078e..2d6f8a7 100644 --- a/docs/cookbook/c/hello world.list.od +++ b/docs/cookbook/c/hello world.list.od @@ -23,6 +23,6 @@ redo-ifchange "$S/sources" done | uniq printf '%s\n' "$LIBGTK2" "$LIBQT4" -) >$3 +) >"$3" -redo-stamp <$3 +redo-stamp <"$3" diff --git a/t/shelltest.od b/t/shelltest.od index 0eee13e..a568b86 100644 --- a/t/shelltest.od +++ b/t/shelltest.od @@ -522,6 +522,18 @@ x2=$(cd shlink && basename "$(pwd -L)") [ "$x1" = "t" ] || fail 122 [ "$x2" = "shlink" ] || fail 123 +# Reported by Wayne Scott on FreeBSD 7.0 (ancient). Apparently the sh (or +# bash?) there prints "$3: ambiguous redirect" if you redirect to it without +# putting the $3 in quotes (ie >"$3"). I hadn't seen that before, even +# though it's not obvious to most sh users that the > argument is implicitly +# quoted. +set a b "shelltest.tmp log.tmp" +rm -f "$3" $3 +echo hello >$3 || fail 130 +[ -e "$3" ] || fail 131 +[ ! -e "shelltest.tmp" ] || fail 132 +rm -f "$3" $3 + [ -e shelltest.failed ] && exit 41 [ -e shelltest.warned ] && exit 42 exit 40