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 uses old \$PATH" "-i echo hello" "hello\n" "" "" 15testcmd "-i env" "-i env" "" "" "" 16testcmd "-i =" "-i one=two three=four $C | sort" \ 17 "one=two\nthree=four\n" "" "" 18testcmd "-0" "-i five=six seven=eight $C -0 | sort -z" "five=six\0seven=eight\0" "" "" 19unset WALRUS BANANA LETTERS FILTER 20 21testcmd "early fail" '--oops 2> /dev/null ; echo $?' "125\n" "" "" 22testcmd "why is this allowed" "=BLAH env | grep '^=BLAH\$'" "=BLAH\n" "" "" 23 24testcmd "replace" "A=foo PATH= `which printenv` A" "foo\n" "" "" 25 26# env bypasses shell builtins 27echo "#!$(which sh) 28echo \$@" > true 29chmod a+x true 30testcmd "norecurse" 'env PATH="$PWD:$PATH" true hello' "hello\n" "" "" 31rm true 32