builtin-redir.sh 612 B

1234567891011121314151617
  1. #!/bin/sh
  2. rm -rf shell-test
  3. mkdir -p shell-test
  4. cd shell-test
  5. time sleep 1 2>timeerr >timeout
  6. cat timeout
  7. # We cannot be sure about the values, so just assert that they're not empty.
  8. test -n "$(cat timeerr)" || echo "Failure: 'time' stderr output not redirected correctly" && exit 1
  9. test -e timeout || echo "Failure: 'time' stdout output not redirected correctly" && exit 1
  10. time ls 2> /dev/null | head > timeout
  11. test -n "$(cat timeout)" || echo "Failure: 'time' stdout not piped correctly" && exit 1
  12. cd ..
  13. rm -rf shell-test # TODO: Remove this file at the end once we have `trap'