git » libfiu » commit ed26a7c

preload/run: Add a dry-run option to fiu-run

author Alberto Bertogli
2014-06-16 01:06:19 UTC
committer Alberto Bertogli
2014-06-16 01:06:19 UTC
parent 15d666d2d304b37801bbafa46a3794b717cf9251

preload/run: Add a dry-run option to fiu-run

This patch adds a new option, -n, to make fiu-run show the command line
instead of executing the program.

It can be useful when you need to run things manually (for example, under
gdb).

preload/run/fiu-run.in +16 -2

diff --git a/preload/run/fiu-run.in b/preload/run/fiu-run.in
index 0fe385f..8926094 100644
--- a/preload/run/fiu-run.in
+++ b/preload/run/fiu-run.in
@@ -20,6 +20,9 @@ PRELOAD_LIBS=""
 # use the POSIX preload library?
 USE_POSIX_PRELOAD=0
 
+# don't run, but show the command line instead
+DRY_RUN=0
+
 HELP_MSG="
 Usage: fiu-run [options] program [arguments]
 
@@ -96,7 +99,7 @@ function add_deprecated_enable() {
 }
 
 opts_reset;
-while getopts "+c:f:l:xe:p:u:i:h" opt; do
+while getopts "+c:f:l:xne:p:u:i:h" opt; do
 	case $opt in
 	c)
 		# Note we use the newline as a command separator.
@@ -112,6 +115,9 @@ while getopts "+c:f:l:xe:p:u:i:h" opt; do
 	x)
 		USE_POSIX_PRELOAD=1
 		;;
+	n)
+		DRY_RUN=1
+		;;
 
 	# Deprecated options
 	e)
@@ -155,5 +161,13 @@ fi
 export FIU_ENABLE="$ENABLE"
 export FIU_CTRL_FIFO="$FIFO_PREFIX"
 export LD_PRELOAD="$PLIBPATH/fiu_run_preload.so $PRELOAD_LIBS"
-exec "$@"
+
+if [ $DRY_RUN -eq 1 ] ; then
+	echo "FIU_ENABLE=\"$ENABLE\"" \\
+	echo "FIU_CTRL_FIFO=\"$FIFO_PREFIX\"" \\
+	echo "LD_PRELOAD=\"$PLIBPATH/fiu_run_preload.so $PRELOAD_LIBS\"" \\
+	echo "$@"
+else
+	exec "$@"
+fi