32 lines
1.1 KiB
Bash
Executable File
32 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
[ -f testing.sh ] && . testing.sh
|
|
|
|
#testcmd "name "args" "result" "infile" "stdin"
|
|
#testing "name" "command" "result" "infile" "stdin"
|
|
|
|
export WALRUS=42 BANANA=hello LETTERS=
|
|
FILTER="| egrep '^(WALRUS|BANANA|LETTERS)=' | sort"
|
|
|
|
testcmd "read" "$FILTER" "BANANA=hello\nLETTERS=\nWALRUS=42\n" "" ""
|
|
testcmd "-u" "-u BANANA $FILTER" "LETTERS=\nWALRUS=42\n" "" ""
|
|
testcmd "-uu" "-u LETTERS -u WALRUS $FILTER" "BANANA=hello\n" "" ""
|
|
testcmd "-i uses old \$PATH" "-i echo hello" "hello\n" "" ""
|
|
testcmd "-i env" "-i env" "" "" ""
|
|
testcmd "-i =" "-i one=two three=four $C | sort" \
|
|
"one=two\nthree=four\n" "" ""
|
|
testcmd "-0" "-i five=six seven=eight $C -0 | sort -z" "five=six\0seven=eight\0" "" ""
|
|
unset WALRUS BANANA LETTERS FILTER
|
|
|
|
testcmd "early fail" '--oops 2> /dev/null ; echo $?' "125\n" "" ""
|
|
testcmd "why is this allowed" "=BLAH env | grep '^=BLAH\$'" "=BLAH\n" "" ""
|
|
|
|
testcmd "replace" "A=foo PATH= `which printenv` A" "foo\n" "" ""
|
|
|
|
# env bypasses shell builtins
|
|
echo "#!$(which sh)
|
|
echo \$@" > true
|
|
chmod a+x true
|
|
testcmd "norecurse" 'env PATH="$PWD:$PATH" true hello' "hello\n" "" ""
|
|
rm true
|