Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#!/bin/bash
set -eo pipefail

export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"
# Safely append Homebrew bins to PATH if they exist, to avoid overriding custom toolchains
if [[ ":$PATH:" != *":/opt/homebrew/bin:"* ]] && [ -d "/opt/homebrew/bin" ]; then
export PATH="$PATH:/opt/homebrew/bin"
fi
if [[ ":$PATH:" != *":/usr/local/bin:"* ]] && [ -d "/usr/local/bin" ]; then
export PATH="$PATH:/usr/local/bin"
Comment on lines +6 to +9

Copilot AI Apr 20, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appending with export PATH="$PATH:/opt/homebrew/bin" (and similarly for /usr/local/bin) will introduce an empty PATH element if $PATH is empty/unset, which makes the current working directory searchable (PATH=":/opt/homebrew/bin"). Consider using a safe append pattern (e.g., only add the : when $PATH is non-empty) to avoid this security/behavior risk.

Suggested change
export PATH="$PATH:/opt/homebrew/bin"
fi
if [[ ":$PATH:" != *":/usr/local/bin:"* ]] && [ -d "/usr/local/bin" ]; then
export PATH="$PATH:/usr/local/bin"
export PATH="${PATH:+$PATH:}/opt/homebrew/bin"
fi
if [[ ":$PATH:" != *":/usr/local/bin:"* ]] && [ -d "/usr/local/bin" ]; then
export PATH="${PATH:+$PATH:}/usr/local/bin"

Copilot uses AI. Check for mistakes.
fi

echo "=============================================="
echo " SwiftLM Build Script "
Expand Down
Loading