export LC_ALL=C export LANG=C # catch-all for remaining untested redirection stuff set +o posix echo abc > /tmp/redir-test cat /tmp/redir-test set -o noclobber #this should be an error echo def > /tmp/redir-test cat /tmp/redir-test # but this should succeed echo def > /tmp/redir-test-2 cat /tmp/redir-test-2 # and so should this echo def >| /tmp/redir-test cat /tmp/redir-test set +o noclobber rm /tmp/redir-test /tmp/redir-test-2 # this should be an error z="a b" cat < $z echo "Point 1" exec 3/tmp/bash-a exec 5>/tmp/bash-b echo "Point 2" echo to a 1>&4 echo to b 1>&5 cat /tmp/bash-a cat /tmp/bash-b exec 11&4 echo to b 1>&5 cat /tmp/bash-a cat /tmp/bash-b exec 11<&- echo "Point 4" exec 6<>/tmp/bash-c echo to c 1>&6 cat /tmp/bash-c echo "Point 5" rm -f /tmp/bash-a /tmp/bash-b /tmp/bash-c # # Test the effect of input buffering on the shell's input # ${THIS_SH} < redir1.sub # more open, close, duplicate file descriptors ${THIS_SH} ./redir3.sub < ./redir3.in1 # still more redirections ${THIS_SH} ./redir4.sub < redir4.in1 # various forms of null redirection testf() { if [ -f "$1" ]; then rm -f "$1" else echo oops -- $1 not found fi } > /tmp/null-redir-a testf /tmp/null-redir-a $EXIT > /tmp/null-redir-b testf /tmp/null-redir-b ( > /tmp/null-redir-c ) testf /tmp/null-redir-c $EXIT > /tmp/null-redir-d & wait testf /tmp/null-redir-d exit 3 | $EXIT > /tmp/null-redir-e echo $? -- ${PIPESTATUS[@]} testf /tmp/null-redir-e exit 4 | > /tmp/null-redir-f echo $? -- ${PIPESTATUS[@]} testf /tmp/null-redir-f > /tmp/null-redir-g & wait testf /tmp/null-redir-g exec >/tmp/null-redir-h & wait testf /tmp/null-redir-h # make sure async commands don't get /dev/null as stdin when an explicit # input redirection is supplied for x in 1 2 3; do { read line ; echo $line ; } & wait { read line ; echo $line ; } & wait done << EOF ab cd ef gh ij kl EOF # make sure async commands get /dev/null as stdin in the absence of any # input redirection /bin/cat & wait echo $? # make sure that loops work OK with here documents and are not run in # subshells while read line; do echo $line l2=$line done << EOF ab cd EOF echo $l2 # These should not echo anything -- bug in versions before 2.04 ( ( echo hello 1>&3 ) 3>&1 ) >/dev/null 2>&1 ( ( echo hello 1>&3 ) 3>&1 ) >/dev/null 2>&1 | cat # in posix mode, non-interactive shells are not allowed to perform # filename expansion on input redirections, even if they expand to # a single filename set -o posix cat < redir1.*