From 6836ed99c8a0d18646ca384afcc57643747478f6 Mon Sep 17 00:00:00 2001 From: Ryan Jacobs Date: Sat, 16 Sep 2023 17:33:57 -0700 Subject: [PATCH] only execute if bin compiled --- c | 13 +++++++++---- tests/test.sh | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/c b/c index 3980e21..3621cb9 100755 --- a/c +++ b/c @@ -34,7 +34,7 @@ cleanup() { # Handle --help, -h, and zero args [[ "$1" == "--help" || "$1" == "-h" ]] && { help_msg 1; exit 0; } -[[ "$#" -lt 1 ]] && { help_msg 2; exit 1; } +[[ "$#" -lt 1 ]] && { help_msg 2; exit 2; } # ensure our $CC and $CXX variables are set [[ -z "$CC" ]] && CC=cc @@ -155,9 +155,14 @@ binname="$tmproot/$id.bin" run() { trap cleanup SIGINT - shift - (exec -a "$fname" "$binname" "$@") - ret=$? + if [ -x "$binname" ]; then + shift + (exec -a "$fname" "$binname" "$@") + ret=$? + else + echo + ret=4 + fi trap - SIGINT cleanup diff --git a/tests/test.sh b/tests/test.sh index 4053f42..3711835 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -9,7 +9,7 @@ source "./test_helpers.sh" [ -n "$CC" ] && "$CC" --version [ -n "$CXX" ] && "$CXX" --version [ -n "$FC" ] && "$FC" --version -c --version +$c --version # Run tests source ./argument_and_link_test/test.sh