Conversation
README.md
Outdated
| fi | ||
| } | ||
|
|
||
| cdnvm "$PWD" || exit |
There was a problem hiding this comment.
is the intention here that if cdnvm fails, the alias should not be set?
There was a problem hiding this comment.
Yes, this was meant to address https://www.shellcheck.net/wiki/SC2164, but I think it's surprising with the reordering which was meant to keep the cdnvm code together and the alias after and separate since shellcheck advised against using an alias in the same parsing unit: https://www.shellcheck.net/wiki/SC2262
To adhere more to the principle of least surprise, I'm going to reorder it back and still have the exit:
# ...
alias cd='cdnvm'
cdnvm "$PWD" || exit
# ...There was a problem hiding this comment.
The instructions on using the cdnvm function say to put the function definition at the end of your .bashrc, then put these two lines after the function definition:
alias cd='cdnvm'
cdnvm "$PWD" || exit
In the event cdnvm fails, this would exit the shell. Is this the desired outcome? Would it not be better to simply delete the alias?
alias cd='cdnvm'
cdnvm "$PWD" || { echo "cdnvm failed; unaliasing" >&2; unalias cd; }
Is there something else I'm missing?
(And is there a better forum to ask this question?)
Resolves #3081