-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
become a safer shell script #868
Comments
Using nonzero exit codes for flow control is a normal part of programming, and In addition, Note that this particular In other words, these shell options are a crutch that both interfere with normal operation as well as enable developers to not properly check all possible failure conditions. |
About
WRT |
That's a fair point - I'll be happy to fix that variable check by checking If you can point at specific instances where |
…t` bash option. Partially fixes nvm-sh#868.
I've taken care of the |
Reopening this in case someone wants to attempt to identify and fix these issues. |
I've found the following unbound variables so far:
NVM version: v0.30.1 |
|
@danistefanovic I see how |
"Unbound variable" is the error message in the terminal if you enable the set -o nounset
. ./nvm/nvm.sh ./nvm/nvm.sh: line 77: NVM_DIR: unbound variable I understand that if [ -z "${NVM_DIR-}" ]; then
# instead of
# if [ -z "$NVM_DIR" ]; then This seems to work with the |
Thanks, this has actually helped me find a ton of these already. I'm going to do a full pass, and I'll close this issue with that commit. |
Glad I could help 🍻 |
Hi there ! Just ran into another unbound variable issue :(
This error occurs when I have the Version of NVM: 0.31.0 |
Thanks, will fix. |
@ljharb Awesome. I forked the repo and was about to send a Pull Request, but I guess it's better to leave that to you :) |
@stouf thanks! PRs are always welcome but this is small enough that it's nbd ¯_(ツ)_/¯ |
In our CI setup, we prefix shell scripts with
in order to make sure script errors will become more obvious. However, I can only enable these lines after including
nvm.sh
due to this error:Please consider adding the aforementioned shell settings in your code (and to fix unbound variable access).
Debug Info
The text was updated successfully, but these errors were encountered: