sigpipe.sh 645 B

1234567891011121314151617181920
  1. #!/bin/sh
  2. source $(dirname "$0")/test-commons.inc
  3. # `head -n 1` should close stdout of the `Shell -c` command, which means the
  4. # second echo should exit unsuccessfully and sigpipe.sh.out should not be
  5. # created.
  6. rm -f sigpipe.sh.out
  7. { echo foo && echo bar && echo baz > sigpipe.sh.out } | head -n 1 > /dev/null
  8. # Failing commands don't make the test fail, just an explicit `exit 1` does.
  9. # So the test only fails if sigpipe.sh.out exists (since then `exit 1` runs),
  10. # not if the `test` statement returns false.
  11. if test -e sigpipe.sh.out {
  12. rm -f sigpipe.sh.out
  13. fail sigpipe did not terminate further commands
  14. } else {
  15. echo PASS
  16. }