3 test_description
='various sanity checks
5 Most of these are "tolerate_failure" checks
6 as there are workarounds in place for them.
17 test_expect_success
'POSIX tr to NUL processing' '
18 printf "1x2x3x" | tr "x" "\\000" >lines3z &&
19 val="$(xargs -0 <lines3z printf "%s\n" | wc -l)" &&
23 test_expect_success
'POSIX tr from NUL processing' '
24 val="$(echo "x@@@y" | tr "x@y" "1\\0005" | tr "\\000" 2)" &&
25 test z"$val" = z"12225"
30 test_tolerate_failure
'POSIX unset behavior' '
31 test z"$(unset it && unset it && echo good || echo bad)" = z"good"
34 test_tolerate_failure
'POSIX exec behavior' '
35 test z"$(false() { :; }; (exec false) && echo "bad" || echo "good")" = z"good"
38 test_tolerate_failure
'POSIX eval behavior' '
39 setec() { ! : || eval "ec=\$?"; } &&
40 setec && test z"$ec" = z"1"
43 test_tolerate_failure
'POSIX trap EXIT behavior' '
44 nomsg() { trap "echo bad" EXIT; } &&
45 result="$(nomsg && trap - EXIT)" &&
46 test z"${result:-good}" = z"good"
49 test_tolerate_failure
'POSIX alias' '
53 test_tolerate_failure LASTOK
'POSIX unalias -a (no subshell)' '
58 test_tolerate_failure LASTOK
'POSIX unalias -a (subshell w/o aliases)' '
62 test_tolerate_failure
'POSIX function redir ops' '
67 test z"$(redir && echo good)" = z"good"
70 test_tolerate_failure
'unsettable LINENO' '
71 { unset LINENO || :; }
74 test_tolerate_failure
'working awk implementation' '
75 # mawk will have a segmentation fault with this
89 test_tolerate_failure
'POSIX awk pattern brace quantifiers' '
90 # mawk stupidly does not support these
91 # can you hear us mocking you mawk?
92 result="$(echo not-mawk | awk "/^[a-z-]{5,}\$/")" &&
93 test z"$result" = z"not-mawk"
96 test_tolerate_failure
'POSIX awk ENVIRON array' '
97 EVAR="This is some test here" &&
99 val="$(awk "BEGIN{exit}END{print ENVIRON[\"EVAR\"]}")" &&
100 test z"$val" = z"$EVAR"
103 test_tolerate_failure
'POSIX export unset var exports it' '
104 say_color info "# POSIX is, regrettably, quite explicit about this" &&
105 say_color info "# POSIX requires EVERY exported variable to be in child environment" &&
107 export NO_SUCH_VAR &&
108 printenv NO_SUCH_VAR >/dev/null