From 1f1db8a82a0a3da0b0de9aa6cb69da4605ae1c79 Mon Sep 17 00:00:00 2001 From: Jim Geoshua Bactad Date: Sat, 7 Feb 2026 11:27:31 +0800 Subject: [PATCH 1/2] fix: Enable launcher script to work from any directory via symlink - Add symlink resolution to find actual script location - Change to project directory before executing - Move .env loading after directory change - Allows script to be called from ~/.local/bin or any location --- start-automaker.sh | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/start-automaker.sh b/start-automaker.sh index 6770db2ca..3b6eee22e 100755 --- a/start-automaker.sh +++ b/start-automaker.sh @@ -9,13 +9,29 @@ set -e # ============================================================================ # CONFIGURATION & CONSTANTS # ============================================================================ +APP_NAME="Automaker" +# Resolve script directory, following symlinks +SOURCE="${BASH_SOURCE[0]}" +while [ -L "$SOURCE" ]; do + DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" +done +SCRIPT_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)" + +# Change to project directory so all relative paths work +cd "$SCRIPT_DIR" || { + echo "Error: Could not change to project directory: $SCRIPT_DIR" >&2 + exit 1 +} + +# Load .env file if it exists (must be after cd to project directory) if [ -f .env ]; then set -a . ./.env set +a fi -APP_NAME="Automaker" -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + HISTORY_FILE="${HOME}/.automaker_launcher_history" MIN_TERM_WIDTH=70 MIN_TERM_HEIGHT=20 @@ -1158,9 +1174,6 @@ fi # Execute the appropriate command case $MODE in web) - if [ -f .env ]; then - export $(grep -v '^#' .env | xargs) - fi export TEST_PORT="$WEB_PORT" export VITE_SERVER_URL="http://${APP_HOST}:$SERVER_PORT" export PORT="$SERVER_PORT" From a29cbd12f0a8be7cdf57ee53b86aa5a43dbcdedf Mon Sep 17 00:00:00 2001 From: Jim Geoshua Bactad Date: Sat, 7 Feb 2026 15:47:17 +0800 Subject: [PATCH 2/2] refactor: Address code review feedback - Remove unused APP_NAME variable (flagged by Shellcheck SC2034) - Add validation for broken symlinks before proceeding - Improves error handling and script robustness --- start-automaker.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/start-automaker.sh b/start-automaker.sh index 3b6eee22e..2d4b94ba7 100755 --- a/start-automaker.sh +++ b/start-automaker.sh @@ -9,7 +9,6 @@ set -e # ============================================================================ # CONFIGURATION & CONSTANTS # ============================================================================ -APP_NAME="Automaker" # Resolve script directory, following symlinks SOURCE="${BASH_SOURCE[0]}" while [ -L "$SOURCE" ]; do @@ -17,6 +16,13 @@ while [ -L "$SOURCE" ]; do SOURCE="$(readlink "$SOURCE")" [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" done + +# Verify the resolved script exists (detect broken symlinks) +if [ ! -f "$SOURCE" ]; then + echo "Error: Script file not found after resolving symlinks: $SOURCE" >&2 + exit 1 +fi + SCRIPT_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)" # Change to project directory so all relative paths work