builtin-redir.sh 674 B

123456789101112131415161718192021
  1. #!/bin/sh
  2. source $(dirname "$0")/test-commons.inc
  3. rm -rf /tmp/shell-test 2> /dev/null
  4. mkdir -p /tmp/shell-test
  5. pushd /tmp/shell-test
  6. time sleep 1 2>timeerr >timeout
  7. cat timeout
  8. # We cannot be sure about the values, so just assert that they're not empty.
  9. if not test -n "$(cat timeerr)" { fail "'time' stderr output not redirected correctly" }
  10. if not test -e timeout { fail "'time' stdout output not redirected correctly" }
  11. time ls 2> /dev/null | head > timeout
  12. if not test -n "$(cat timeout)" { fail "'time' stdout not piped correctly" }
  13. popd
  14. rm -rf /tmp/shell-test # TODO (#7339): Remove this file at the end once we have `trap'
  15. echo PASS