libinput/test/helper-copy-and-exec-from-tmp.sh
Peter Hutterer d4f5faae0d tools: move the builddir lookup function out to a separate file
We want to use this from the tests as well soon, so let's move it to a more
generic location. This also changes the API to be slightly more sensible, a
free() is the same cost (and safer) than passing a static buffer in and hoping
we didn't get the size wrong.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-03-14 11:28:05 +10:00

18 lines
375 B
Bash
Executable file

#!/bin/bash -x
#
# Usage: helper-copy-and-exec-from-tmp.sh /path/to/binary [args]
#
# Copies the given binary into a unique file in /tmp and executes it with
# [args]. Exits with the same return code as the binary did.
executable="$1"
shift
target_name=$(mktemp)
cp "$executable" "$target_name"
chmod +x "$target_name"
"$target_name" "$@"
rc=$?
rm "$target_name"
exit $rc