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"
fi
Relevant file: binary-installer/install.sh.
Context
N/A
Issue description
binary-installer/install.shhas non-idempotentPATHinsertion logic in bash profile handling.Problematic checks:
if [[ ! $(grep -q '.serverless/bin' $SHELL_CONFIG) ]]; then(around lines 74, 80)grep -qintentionally produces no stdout, so$(grep -q ...)expands to an empty string regardless of match result.As a result,
[[ ! $(...) ]]evaluates true andadd_to_pathruns even when.serverless/binis already present.Effect
Running the installer repeatedly appends duplicate blocks like:
This causes shell startup files to grow and can repeatedly prepend the same directory in
PATH.Reproduction
Ensure
~/.bash_profile existsand already contains.serverless/bin.Run
binary-installer/install.sh.Observe that the installer appends another
# Added by serverless binary installerblock.Run it again and see additional duplicates.
Expected behavior
Installer should be idempotent and only add PATH config when
.serverless/binis not already configured.Suggested fix
Use
grepexit status directly instead of command substitution, for example:Relevant file:
binary-installer/install.sh.Context
N/A