summaryrefslogtreecommitdiff
path: root/CMake/run_if_exists.sh
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2016-08-10 16:19:00 +0200
committerJulian Andres Klode <jak@debian.org>2016-08-10 16:19:00 +0200
commite02c3a9ec2b2f7a8d4aecd70f2ecdae27c207aa9 (patch)
treeffa99f96949f3eab728a1b8caecdd014ea8d6f81 /CMake/run_if_exists.sh
parentb2cfacf1180e4b3fcbb2ae2ea52cf270ef74e971 (diff)
parent61fef4ddbec8f70bb9e213ac0491d4e6cfefab30 (diff)
Merge branch 'cmake'
Diffstat (limited to 'CMake/run_if_exists.sh')
-rwxr-xr-xCMake/run_if_exists.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/CMake/run_if_exists.sh b/CMake/run_if_exists.sh
new file mode 100755
index 000000000..97edd4c1a
--- /dev/null
+++ b/CMake/run_if_exists.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+# Small helper for running a command
+out=""
+if [ "$1" = "--stdout" ]; then
+ out="$2"
+ shift 2
+fi
+
+if [ -e "$1" ]; then
+ shift
+ if [ "$out" ]; then
+ exec "$@" > $out
+ else
+ exec "$@"
+ fi
+fi