Skip to content

Commit

Permalink
#1087 Fix sdkman_auto_env when PROMPT_COMMAND ends with space (#1088)
Browse files Browse the repository at this point in the history
Trim PROMPT_COMMAND
Without this fix there may be a message with double semicolon:
bash: PROMPT_COMMAND: line 0: `history -a; history -n; ;sdkman_auto_env'
  • Loading branch information
speedlog committed Apr 21, 2022
1 parent 469f83b commit 0906561
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/bash/sdkman-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,9 @@ if [[ "$sdkman_auto_env" == "true" ]]; then

export SDKMAN_OLD_PWD="$PWD"
}

[[ -z "$PROMPT_COMMAND" ]] && PROMPT_COMMAND="sdkman_auto_env" || PROMPT_COMMAND="${PROMPT_COMMAND%\;};sdkman_auto_env"

trimmed_prompt_command="${PROMPT_COMMAND%"${PROMPT_COMMAND##*[![:space:]]}"}"
[[ -z "$trimmed_prompt_command" ]] && PROMPT_COMMAND="sdkman_auto_env" || PROMPT_COMMAND="${trimmed_prompt_command%\;};sdkman_auto_env"
fi

sdkman_auto_env
Expand Down

0 comments on commit 0906561

Please sign in to comment.