#!/bin/echo no # Testing shell corner cases _within_ a shell script is kind of hard. [ -f testing.sh ] && . testing.sh #testing "name" "command" "result" "infile" "stdin" [ -z "$SH" ] && { [ -z "$TEST_HOST" ] && SH="sh" || export SH="bash" ; } export EVAL="$SH -c" testing "smoketest" "echo hello" "hello\n" "" "" # ; | && || testing "semicolon" "echo one;echo two" "one\ntwo\n" "" "" testing "simple pipe" "echo hello | cat" "hello\n" "" "" testing "&&" "true && echo hello" "hello\n" "" "" testing "&&2" "false && echo hello" "" "" "" testing "||" "true || echo hello" "" "" "" testing "||2" "false || echo hello" "hello\n" "" "" testing "&& ||" "true && false && potato || echo hello" "hello\n" "" "" # redirection testing "" "cat < input" "hello\n" "hello\n" "" testing "" "echo blah >out; cat out" "blah\n" "" "" testing "" "touch /not/exist 2>out||grep -o /not/exist out" "/not/exist\n" "" "" #testing "" 'echo hello | (read i /dev/full\n" "E" "E$P" X0