-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for $path used by zsh #1669
Conversation
"The lower-case version of PATH is an array parameter bound to the scalar upper-case parameter." -- http://www.zsh.org/mla/users/2015/msg00178.html
Thanks; can you add a test that would have failed with this change? |
The "\printf" calls zsh shell builtin instead of `command printf` in scripting. The workaround is no longer needed given 91a29c0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any possibility of an explicit test for this behavior?
command printf %s\\n "$*" 2>/dev/null || { | ||
nvm_echo() { | ||
# shellcheck disable=SC1001 | ||
\printf %s\\n "$*" # on zsh, `command printf` sometimes fails |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow, is the implication here that this failure is solely based on using a var named "path" in nvm_find_up
??
If so, then I think that shellcheck should warn for variables named path
when set to zsh mode - that would have caught this issue much sooner. I'll file one :-) Update: I filed koalaman/shellcheck#1058, but turns out shellcheck doesn't care about zsh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure. Just a guess, and it seems OK after removing the code. (Tests are passed.)
The backslash inactivates alias and has no effect in scripting.
Thus this snippet works as "use shell builtin when command fails".
Note: I just noticed that:
command printf
in bash: is shell builtin in bash
command printf
in zsh: is command /usr/bin/printf
This bug should have been found by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Fixes - fix unassigned variable (nvm-sh#1665, nvm-sh#1664) - Fix for $path used by zsh (nvm-sh#1669) - `set -u`: ensure `NVM_USE_OUTPUT` is always set (nvm-sh#1671) - `install.sh`: Fix a bug that block that installation of node in install.sh (nvm-sh#1676) - `nvm install-latest-npm`: fix node 4-4.6 Documentation - Make `nvm cache clear` message less ambiguous (nvm-sh#1644) - Added missing piece (nvm-sh#1658)
Fix for $path used by zsh
Fixes - fix unassigned variable (nvm-sh#1665, nvm-sh#1664) - Fix for $path used by zsh (nvm-sh#1669) - `set -u`: ensure `NVM_USE_OUTPUT` is always set (nvm-sh#1671) - `install.sh`: Fix a bug that block that installation of node in install.sh (nvm-sh#1676) - `nvm install-latest-npm`: fix node 4-4.6 Documentation - Make `nvm cache clear` message less ambiguous (nvm-sh#1644) - Added missing piece (nvm-sh#1658)
The
$path
is used by zsh itself.Rename
path
topath_
.Ref:
"The lower-case version of PATH is an array parameter
bound to the scalar upper-case parameter."
-- http://www.zsh.org/mla/users/2015/msg00178.html