-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Description
Issue description
binary-installer/install.sh has non-idempotent PATH insertion logic in bash profile handling.
Problematic checks:
if [[ ! $(grep -q '.serverless/bin' $SHELL_CONFIG) ]]; then(around lines 74, 80)
grep -q intentionally produces no stdout, so $(grep -q ...) expands to an empty string regardless of match result.
As a result, [[ ! $(...) ]] evaluates true and add_to_path runs even when .serverless/bin is already present.
Effect
Running the installer repeatedly appends duplicate blocks like:
# Added by serverless binary installer
export PATH="$HOME/.serverless/bin:$PATH"This causes shell startup files to grow and can repeatedly prepend the same directory in PATH.
Reproduction
Ensure ~/.bash_profile exists and already contains .serverless/bin.
Run binary-installer/install.sh.
Observe that the installer appends another # Added by serverless binary installer block.
Run it again and see additional duplicates.
Expected behavior
Installer should be idempotent and only add PATH config when .serverless/bin is not already configured.
Suggested fix
Use grep exit status directly instead of command substitution, for example:
if [[ ! -r "$SHELL_CONFIG" ]] || ! grep -q '.serverless/bin' "$SHELL_CONFIG"; then
add_to_path "$SHELL_CONFIG"
fiRelevant file: binary-installer/install.sh.
Context
N/A