cxreg / smartcd

Alter your bash (or zsh) environment as you cd
Other
682 stars 56 forks source link

bash_enter run twice on smartcd load if $PWD ends in a slash #68

Open von opened 2 years ago

von commented 2 years ago

If $PWD ends in a slash, I'm seeing bash_enter run twice, the second time with two slashes between the directory path and bash_enter. E.g. the following is from a new shell starting in a tmux pane with the initial path being /Users/von/.local/share/chezmoi/:

DEBUG: PWD=/Users/von/.local/share/chezmoi/
DEBUG: source smartcd
smartcd: running /Users/von/.smartcd/scripts/Users/von/.local/share/chezmoi/bash_enter
Setting up chezmoi environment.
smartcd: running /Users/von/.smartcd/scripts/Users/von/.local/share/chezmoi//bash_enter
Setting up chezmoi environment.
DEBUG: source smartcd done

If I trim the slash from the end of $PWD (PWD=${PWD%/}), the double execution goes away:

DEBUG: PWD=/Users/von/.local/share/chezmoi
DEBUG: source smartcd
smartcd: running /Users/von/.smartcd/scripts/Users/von/.local/share/chezmoi/bash_enter
Setting up chezmoi environment.
DEBUG: source smartcd done

Not sure what version of smartcd I'm running as I can't find any sort of version command.