run.sh: print the command that runs
[c11tester.git] / run.sh
diff --git a/run.sh b/run.sh
index fecd43ddefc8b7a2460bb2d595ad9fc868f28fda..00ffd94b338c223710f15198e06f1fd40ca25509 100755 (executable)
--- a/run.sh
+++ b/run.sh
@@ -2,8 +2,9 @@
 #
 # Runs a simple test (default: ./test/userprog.o)
 # Syntax:
-#  ./run.sh [gdb]
-#  ./run.sh [test program] [gdb]
+#  ./run.sh [test program] [OPTIONS]
+#  ./run.sh [OPTIONS]
+#  ./run.sh [gdb [test program]]
 #
 # If you include a 'gdb' argument, the your program will be launched with gdb.
 # You can also supply a test program argument to run something besides the
 #
 
 BIN=./test/userprog.o
+PREFIX=
 
 export LD_LIBRARY_PATH=.
 
-[ $# -gt 0 ] && [ "$1" != "gdb" ] && BIN=$1 && shift
+[ $# -gt 0 ] && [ "$1" = "gdb" ] && PREFIX=gdb && shift
+[ $# -gt 0 ] && [ -x "$1" ] && [ -f "$1" ] && BIN="$1" && shift
 
-if [ $# -gt 0 ]; then
-       if [ "$1" = "gdb" ]; then
-               gdb $BIN
-       else
-               echo "Invalid argument(s)"
-               exit 1
-       fi
-else
-       $BIN
-fi
+set -x
+$PREFIX $BIN $@