helper-copy-and-exec-from-tmp.sh 375 B

123456789101112131415161718
  1. #!/bin/bash -x
  2. #
  3. # Usage: helper-copy-and-exec-from-tmp.sh /path/to/binary [args]
  4. #
  5. # Copies the given binary into a unique file in /tmp and executes it with
  6. # [args]. Exits with the same return code as the binary did.
  7. executable="$1"
  8. shift
  9. target_name=$(mktemp)
  10. cp "$executable" "$target_name"
  11. chmod +x "$target_name"
  12. "$target_name" "$@"
  13. rc=$?
  14. rm "$target_name"
  15. exit $rc