-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
"help" intercepts commands run by exec and run #3126
Comments
The solution here is to use |
(In the future you may want to hold off on a PR until you're sure the maintainer is interested) |
Oh, thank you! I tried adding nvm exec lts/hydrogen -- node --help Good to know this is already implemented. Thanks! Is this something we should add to the docs? |
Sure, let's update your PR to change the docs instead :-) It should be able to appear anywhere. |
# ❌ - shows NVM help
nvm -- exec lts/hydrogen node --help
# ❌ - error in nvm-exec line 15
nvm exec -- lts/hydrogen node --help
# ✅ - works perfectly
nvm exec lts/hydrogen -- node --help
# ❌ - nodejs: module not found "--help"
nvm exec lts/hydrogen node -- --help My initial attempt was the 4th one, but this results in Node.js |
it certainly has to go after |
For interest, an alternative approach is to have
|
@shadowspawn i worry that would cause problems if there's nvm-specific options passed to I certainly think that anything that's not used by nvm should be passed through, though. |
Given that |
Command
What happened?
NVM outputs its help command.
What did you expect to happen?
I expected the
--help
flag to be passed tonode
Potential Solution
I understand why the
help
command takes precedense since its useful for just plopping it at the end of a command to get help on said command. However, this really ruins any situations where one might be usingnvm exec
as a replacement tonode
, effectively making it a pain to run anything else's help command.My primary usage is to use nvm behind-the-scenes as an environment manager, so any time someone specifies "help" in my use-case, it is intended for node, npm, or whatever the command they are running is and not NVM. The user would never be running
nvm
directly, but rather a custom CLI that passes args through NVM when necessary to run them at the correct version without updating the default NVM version that's in use elsewhere on the user's machine.Thus, I propose
NVM_NO_HELP=1
.This flag, if specified, will instruct NVM to not respond to help requests.
I'm not very skilled with bash so I imagine there's a better solution out there; but the code snippet above works on my local installation of nvm and lets me bypass the help command.
Conclusion
Please let me know if you think this is something that is worth fixing in future versions of NVM. It would certainly help my use-case and allow me to avoid modifying
nvm.sh
just to escape help commands.Thanks.
The text was updated successfully, but these errors were encountered: