Skip to content

Commit 7420faf

Browse files
ezoushenclaude
andcommitted
fix: use cd -P to resolve symlinks to physical directory
The previous approach resolved the symlink path but didn't follow it to the physical directory. On Homebrew: - Symlink: /opt/homebrew/bin/axon → ../Cellar/axon/0.1.4/libexec/axon - We were getting: /opt/homebrew/Cellar/axon/0.1.4/bin/axon (wrong!) - We needed: /opt/homebrew/Cellar/axon/0.1.4/libexec/axon (correct!) Now using 'cd -P' which follows symlinks to physical directories. This is a standard Bash pattern for resolving script locations. Fixes Homebrew installation on macOS where lib files are in libexec/ not bin/. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a7a40d5 commit 7420faf

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.4
1+
0.1.5

axon

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,15 @@ CYAN='\033[0;36m'
1616
NC='\033[0m'
1717

1818
# Script directory (resolve symlinks for Homebrew compatibility)
19-
if [[ -L "${BASH_SOURCE[0]}" ]]; then
20-
# If script is a symlink (Homebrew), resolve to absolute real path
21-
SYMLINK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
22-
SYMLINK_NAME="$(basename "${BASH_SOURCE[0]}")"
23-
REAL_SCRIPT="$(readlink "$SYMLINK_DIR/$SYMLINK_NAME")"
24-
25-
# Handle relative symlinks by resolving from symlink directory
26-
if [[ "$REAL_SCRIPT" != /* ]]; then
27-
REAL_SCRIPT="$SYMLINK_DIR/$REAL_SCRIPT"
28-
fi
29-
30-
SCRIPT_DIR="$(cd "$(dirname "$REAL_SCRIPT")" && pwd)"
31-
else
32-
# If script is not a symlink (git submodule), use normal resolution
33-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
34-
fi
19+
# We need to follow symlinks to find the real script location
20+
SOURCE="${BASH_SOURCE[0]}"
21+
while [[ -L "$SOURCE" ]]; do
22+
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
23+
SOURCE="$(readlink "$SOURCE")"
24+
# If SOURCE is relative, resolve it relative to the symlink's directory
25+
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
26+
done
27+
SCRIPT_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
3528
PRODUCT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
3629

3730
# Source command parser library

0 commit comments

Comments
 (0)