-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Fix error with zsh aliases in nvm_print_color_code #2365
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
Conversation
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.
Unfortunately when I run nvm_print_color_code R
, with alias -g R='| less -S'
set, with this change, I still don't get the expected output of 1;31m
.
A regression test might be helpful.
(cc @naomiquinones @gitburd for possibly a bizarre zsh behavior with case statements and global aliases that #2291 may have exposed) |
It works on my machine 🤷 |
With |
@hosamaly indeed, that does bypass the issue - even without this PR's change. However, aliases in everything but zsh can't appear except in command position, and it seems like in zsh, it can appear in any position :-/ We can certainly try modifying nvm to invoke |
Would it makes sense to update just this function to quote or \ the input, since it takes a single character input, which is more likely to be a global alias than a more specific input is? Or should we wait for an alternative solution? |
That seems like a reasonable middle ground, for now, but I’d prefer a long-term solution - perhaps like i do for IFS (re-invoke nvm with out any zsh aliases, or something) |
@ljharb The changes in this PR made it so that with |
I'm happy to land this PR asap that quotes them; I was able to reproduce this error by setting the alias before sourcing nvm.sh in my |
febe219
to
5ac71ce
Compare
I'm trying to add a test, but it's not reproducing the failure :-/ |
@ljharb I tried to reproduce the error using the aliases defined on my machine, but the tests still pass. However, I don't think that a fix must wait until a reproducible test is available. I think that the fix is ready to be merged because a) it looks safe (from a code review standpoint), b) it doesn't cause any tests to fail, and c) a few people reported that it fixed the issue. What do you think? |
@hosamaly that's a fair point; and I could certainly land the quotes as-is, but without a regression test, it's highly likely it'll break in the future - and it's also likely i'll forget to add the test later if the fix is already merged :-) I'll probably land it without a test in the next week or so, but it'd be really nice to have a test first. |
@ljharb I was able to write a test where sourcing nvm.sh fails by moving it from setup to a new test file. |
cd4ec40
to
622b53d
Compare
Thanks! I've pulled that in and confirmed it fails the sourcing tests, only in zsh: https://travis-ci.com/github/nvm-sh/nvm/jobs/472555823 However, I then applied the fix on top, and they're still not passing :-/ so perhaps we still need a different fix? |
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.
…ctions Followup to nvm-sh#2365.
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
Hopefully fixes #2362