test/helper-copy-and-exec-from-tmp.sh
raw| 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 | |
| 8 | executable="$1" |
| 9 | shift |
| 10 | |
| 11 | target_name=$(mktemp) |
| 12 | cp "$executable" "$target_name" |
| 13 | chmod +x "$target_name" |
| 14 | |
| 15 | "$target_name" "$@" |
| 16 | rc=$? |
| 17 | rm "$target_name" |
| 18 | exit $rc |