Skip to content

Commit

Permalink
Fix improper use of == with [
Browse files Browse the repository at this point in the history
`==` is only (semi-)portable when used with `[[`.
  • Loading branch information
MPLew-is authored and guenhter committed Feb 21, 2023
1 parent d163b64 commit 08a4af2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions gitprompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -713,12 +713,12 @@ function add_prompt_command() {
return 0
fi

if [ -z "$PROMPT_COMMAND" ]; then
if [[ -z "$PROMPT_COMMAND" ]]; then
PROMPT_COMMAND="$new_entry"
return 0
fi

if [ "$insert_before" == "true" ]; then
if [[ "$insert_before" == "true" ]]; then
PROMPT_COMMAND="${new_entry};${PROMPT_COMMAND}"
else
PROMPT_COMMAND="${PROMPT_COMMAND};${new_entry}"
Expand Down
2 changes: 1 addition & 1 deletion tests/test-non-git-ps1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function test_original_prompt_is_restored() {
# Navigate back into the repo
cd "$REPO_ROOT"
run_prompt_command
if [ "$PS1" == "$" ]; then
if [[ "$PS1" == "$" ]]; then
echo "PS1: $PS1 == \$"
return 1
fi
Expand Down

0 comments on commit 08a4af2

Please sign in to comment.