Skip to content

Commit

Permalink
Fix incompatibility with an exported $CDPATH, fixes magicmonty#501
Browse files Browse the repository at this point in the history
Because gitprompt.sh uses command cd to find __GIT_PROMPT_DIR it
breaks if $CDPATH is used and exported.

* Add unset CDPATH
  • Loading branch information
benvaljean committed Aug 18, 2022
1 parent 148d502 commit 5cd7e35
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions gitprompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function git_prompt_dir() {
# assume the gitstatus.sh is in the same directory as this script
# code thanks to http://stackoverflow.com/questions/59895
if [[ -z "${__GIT_PROMPT_DIR:+x}" ]]; then
unset CDPATH

This comment has been minimized.

Copy link
@guenhter

guenhter Oct 10, 2022

Wouldn't this mean, that when gitprompt.sh is sourced, after sourcing the script the CDPATH would be gone? I guess this should not happen, should it? Can you maybe think of another solution without removing the CDPATH?

local SOURCE="${BASH_SOURCE[0]}"
while [[ -h "${SOURCE}" ]]; do
local DIR="$( command cd -P "$( dirname "${SOURCE}" )" && pwd )"
Expand Down

0 comments on commit 5cd7e35

Please sign in to comment.