sigpipe.sh 507 B

12345678910111213
  1. #!/bin/sh
  2. # `head -n 1` should close stdout of the `Shell -c` command, which means the
  3. # second echo should exit unsuccessfully and sigpipe.sh.out should not be
  4. # created.
  5. rm -f sigpipe.sh.out
  6. { echo foo && echo bar && echo baz > sigpipe.sh.out } | head -n 1 > /dev/null
  7. # Failing commands don't make the test fail, just an explicit `exit 1` does.
  8. # So the test only fails if sigpipe.sh.out exists (since then `exit 1` runs),
  9. # not if the `test` statement returns false.
  10. test -e sigpipe.sh.out && exit 1