3 test_description
='various sanity checks
5 Most of these are "tolerate_failure" checks
6 as there are workarounds in place for them.
15 test_tolerate_failure
'POSIX unset behavior' '
16 test z"$(unset it && unset it && echo good || echo bad)" = z"good"
19 test_tolerate_failure
'POSIX exec behavior' '
20 test z"$(false() { :; }; (exec false) && echo "bad" || echo "good")" = z"good"
23 test_tolerate_failure
'POSIX eval behavior' '
24 setec() { ! : || eval "ec=\$?"; } &&
25 setec && test z"$ec" = z"1"
28 test_tolerate_failure
'POSIX trap EXIT behavior' '
29 nomsg() { trap "echo bad" EXIT; } &&
30 result="$(nomsg && trap - EXIT)" &&
31 test z"${result:-good}" = z"good"
34 test_tolerate_failure
'POSIX alias' '
38 test_tolerate_failure LASTOK
'POSIX unalias -a (no subshell)' '
43 test_tolerate_failure LASTOK
'POSIX unalias -a (subshell w/o aliases)' '
47 test_tolerate_failure
'POSIX function redir ops' '
52 test z"$(redir && echo good)" = z"good"
55 test_tolerate_failure
'unsettable LINENO' '
56 { unset LINENO || :; }
59 test_tolerate_failure
'working awk implementation' '
60 # mawk will have a segmentation fault with this
74 test_tolerate_failure
'POSIX awk pattern brace quantifiers' '
75 # mawk stupidly does not support these
76 # can you hear us mocking you mawk?
77 result="$(echo not-mawk | awk "/^[a-z-]{5,}\$/")" &&
78 test z"$result" = z"not-mawk"
81 test_tolerate_failure
'POSIX awk ENVIRON array' '
82 EVAR="This is some test here" &&
84 val="$(awk "BEGIN{exit}END{print ENVIRON[\"EVAR\"]}")" &&
85 test z"$val" = z"$EVAR"
88 test_tolerate_failure
'POSIX tr NUL processing' '
89 val="$(perl -e "print 1,\"\\000\" x 3, 5" | tr "\\000" 2)" &&
90 test z"$val" = z"12225"
93 test_tolerate_failure
'POSIX export unset var exports it' '
94 say_color info "# POSIX is, regrettably, quite explicit about this" &&
95 say_color info "# POSIX requires EVERY exported variable to be in child environment" &&
98 printenv NO_SUCH_VAR >/dev/null