From 07163d81cf6aa596076e5e0b42fa3d16515cc3d7 Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Tue, 4 Dec 2018 02:32:14 -0500 Subject: [PATCH] shelltest.od: detect some weird zsh problems. This seems to only affect old zsh on MacOS. But we want to catch it anyway, because it caused t/351-deps-forget to fail in a weird way on that version of zsh. Shells really suck. --- t/shelltest.od | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/t/shelltest.od b/t/shelltest.od index 3ffafd1..8dbebd1 100644 --- a/t/shelltest.od +++ b/t/shelltest.od @@ -304,6 +304,30 @@ t8=$(a=1 f8) [ "$t8" = "1" ] || fail 88 +# Some versions of zsh (eg. 5.0.8 on MacOS, but not 5.3.1 +# on Debian) fail this one. It seems to be very specific: +# "set -e" aborts the subshell, if a +# function-within-a-function returns an error code, even +# though there's an "|| true" there, but only if in the +# else clause, and only if the outer () does *not* have an +# "|| something" clause. +# +# "x || true" should not abort when set -e, even if x is +# a function. +( + set -e + f() { false; } + g() { true | f; } + if false; then + : + else + ! g || true + fi +) +rv=$? +[ "$rv" = 0 ] || fail 89 + + # http://www.gnu.org/software/hello/manual/autoconf/Limitations-of-Builtins.html . /dev/null || fail 90 (! : | :) && fail 91 || true @@ -389,5 +413,9 @@ set x y z # dock it some points so it doesn't always end up as the primary shell. [ 1 == 1 ] 2>/dev/null && warn 118 +# Some shells apparently don't support left padding in printf +x=$(printf "a%-5sc" "b") +[ "$x" = "ab c" ] || warn 119 + [ -n "$FAIL" ] || exit 40 exit $FAIL