env.test 1.1 KB

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