From 904ac4523c910be23b22d6b9a88afbf3e9d85fa5 Mon Sep 17 00:00:00 2001 From: tr4m0ryp Date: Sun, 12 Apr 2026 20:06:49 +0200 Subject: [PATCH] fix(#2): validate binary before exec in start.sh Resolves #2: start.sh fails with "Is a directory" error Added pre-exec validation to check the binary exists, is a regular file, and is executable. Improved build failure handling so the script stops with a clear message instead of trying to exec a missing/invalid binary. Files modified: - start.sh Co-Authored-By: Claude Opus 4.6 (1M context) --- start.sh | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/start.sh b/start.sh index e7ff408..e0f257f 100755 --- a/start.sh +++ b/start.sh @@ -213,16 +213,31 @@ install_deps() { # ------------------------------------------------------------------ # build_project() { - if [ -x "$BINARY" ]; then + if [ -f "$BINARY" ] && [ -x "$BINARY" ]; then msg_ok "Binary already built: $BINARY" return 0 fi + # If a directory exists where the binary should be, the build cannot proceed + if [ -d "$BINARY" ]; then + msg_err "Expected binary at $BINARY but found a directory." + msg_info "Remove it and rebuild: rm -rf '$BINARY' && make clean && make" + exit 1 + fi + msg_info "Building tr4mpass..." - (cd "$SCRIPT_DIR" && make clean && make) + if ! (cd "$SCRIPT_DIR" && make clean && make); then + msg_err "Build failed. Check compiler output above." + exit 1 + fi + + if [ ! -f "$BINARY" ]; then + msg_err "Build completed but binary not found at $BINARY." + exit 1 + fi if [ ! -x "$BINARY" ]; then - msg_err "Build failed. Check compiler output above." + msg_err "Binary exists but is not executable. Run: chmod +x $BINARY" exit 1 fi @@ -512,6 +527,22 @@ main() { msg_info "Starting tr4mpass..." echo "" + # Final validation before exec + if [ ! -e "$BINARY" ]; then + msg_err "Binary not found at $BINARY. Build may have failed." + msg_info "Run 'make' manually to see errors." + exit 1 + fi + if [ -d "$BINARY" ]; then + msg_err "Expected binary at $BINARY but found a directory." + msg_info "Remove it and rebuild: rm -rf '$BINARY' && make clean && make" + exit 1 + fi + if [ ! -x "$BINARY" ]; then + msg_err "Binary exists but is not executable. Run: chmod +x $BINARY" + exit 1 + fi + exec "$BINARY" "$@" }