-
Notifications
You must be signed in to change notification settings - Fork 525
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
updater.sh returns with exit code 0 when failing in update_userjs #1810
Comments
I'll let someone else who knows what they're doing handle this request/suggestion (earthlng usually pops in once a month) |
There are already checks to handle this: Line 115 in 33a84b6
Lines 250 to 251 in 33a84b6
Please post the output you are getting @odhil |
after disabling network connection...
this is a problem if the script is run from another script |
unrelated, but shellcheck says...
|
been over two months since requested and I consider this an (expected) edge case |
I think I found the reason. update_userjs function returns 1. this is OK. But after that function, you also call another command ("cd" command) which returns 0. Here is the line: Line 407 in 33a84b6
Shell scripts always return the last exit/return code. Therefore you got 0. I will not open a pull request. Because I don't know why the script needs the "cd" command on the last phase. As a temporary solution, you can can store the last-exit-code and return it: update_userjs
LAST_EXIT_CODE="$?"
cd "$CURRDIR"
exit $LAST_EXIT_CODE |
I already suggested a simpler fix in #1828. The last |
The rewrite focuses on the following five areas of interest: 1. Portability. The scripts should be useable across a number of Unix operating systems and shells; goes hand in hand with POSIX- compliance. 2. Robustness. Fail early; borrow from more battle-tested open source code; pass all valid ShellCheck checks. 3. Composability. Put everything inside functions; make the scripts dot source friendly. 4. Consistency. Abstract away terminal color codes with tput; uniform diagnostic messages and standardized use of status codes and redirections. 5. Readability. Extensive comments and descriptive names; use here- docs to ease writing multiline messages. Known behavioral changes: 1. Changed the way the options are parsed and acted on. For example, when both the -p and -l options of updater.sh are specified, -l will be ignored. The old behavior would depend on the order of the options passed, where the last one wins, and the profile path passed as the argument to -p couldn't be named 'list' or it would be treated as if the option -l was specified. 2. All temporary files are created using mktemp, so users won't find them in the working directory anymore should an error occur and they were not removed as a result of that.
updater.sh returns with exit code 0 when failing to download user.js file, for example, when no internet connection. The assumed result would be to return a non-zero exit code. This way, if the updater fails, one can retry after some time.
One way to solve would be by explicitly returning 0 at the end of update_userjs function when it completes succesfully and calling update_userjs || exit 1 to exit when the update_userjs function returns non-zero value.
The text was updated successfully, but these errors were encountered: