Skip to content

Commit

Permalink
only execute if bin compiled
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmjacobs committed Sep 17, 2023
1 parent 743a303 commit 6836ed9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions c
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test.sh
Expand Up @@ -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
Expand Down

0 comments on commit 6836ed9

Please sign in to comment.