run_if_exists.sh 231 B

1234567891011121314151617
  1. #!/bin/sh
  2. # Small helper for running a command
  3. out=""
  4. if [ "$1" = "--stdout" ]; then
  5. out="$2"
  6. shift 2
  7. fi
  8. if [ -e "$1" ]; then
  9. shift
  10. if [ "$out" ]; then
  11. exec "$@" > $out
  12. else
  13. exec "$@"
  14. fi
  15. fi