1#!/bin/bash 2 3[ -f testing.sh ] && . testing.sh 4 5#testcmd "name "args" "result" "infile" "stdin" 6#testing "name" "command" "result" "infile" "stdin" 7 8export WALRUS=42 BANANA=hello LETTERS= 9FILTER="| egrep '^(WALRUS|BANANA|LETTERS)=' | sort" 10 11testcmd "read" "$FILTER" "BANANA=hello\nLETTERS=\nWALRUS=42\n" "" "" 12testcmd "-u" "-u BANANA $FILTER" "LETTERS=\nWALRUS=42\n" "" "" 13testcmd "-uu" "-u LETTERS -u WALRUS $FILTER" "BANANA=hello\n" "" "" 14testcmd "-i" "-i env" "" "" "" 15testcmd "-i =" "-i one=two three=four env | sort" \ 16 "one=two\nthree=four\n" "" "" 17testcmd "-0" "-i five=six seven=eight env -0 | sort -z" "five=six\0seven=eight\0" "" "" 18unset WALRUS BANANA LETTERS FILTER 19 20testcmd "early fail" '--oops 2> /dev/null ; echo $?' "125\n" "" "" 21testcmd "why is this allowed" "=BLAH env | grep '^=BLAH\$'" "=BLAH\n" "" "" 22 23testcmd "replace" "A=foo PATH= `which printenv` A" "foo\n" "" "" 24 25# env bypasses shell builtins 26echo "#!$(which sh) 27echo \$@" > true 28chmod a+x true 29testcmd "norecurse" 'env PATH="$PWD:$PATH" true hello' "hello\n" "" "" 30rm true 31