Answer by DevOps-Eng for How can I get this script to error exit based on...
You can simply add the --fail option to the curl command, this will solve your problem, the script will fail and exit on error if the curl command fails, if very useful too when using curl in jenkins...
View ArticleAnswer by G32RW for How can I get this script to error exit based on result...
If errexit is set and the curl command fails the script terminates right after the failed curl command. In the bash manual there is no hint that set -e ignores any failed return status of a single in a...
View ArticleAnswer by rexkogitans for How can I get this script to error exit based on...
set -o errexit can be tricky in loops and subshells, because you have to pass the way back out of the process. Breaking a loop (even in normal operation) is considered bad practice. You can call me...
View ArticleAnswer by RobertL for How can I get this script to error exit based on result...
If you have errexit set, then the false statement should cause the script to exit immediately. Same thing if the curl command failed. You're example script, as written, should exit after the first curl...
View ArticleAnswer by John1024 for How can I get this script to error exit based on...
Replace: done with: done || exit 1 This will cause the code to exit if the for loop exits with a non-zero exit code. As a point of trivia, the 1 in exit 1 is not needed. A plain exit command would exit...
View ArticleHow can I get this script to error exit based on result of for loop?
I have a bash script which uses set -o errexit so that on error the entire script exits at the point of failure. The script runs a curl command which sometimes fails to retrieve the intended file -...
View ArticleAnswer by Max Bileschi for How can I get this script to error exit based on...
If you prefer to stop the loop on the first failure, and also to avoid set -e, you can do something like this:for i in `seq 1 10`; do run_command || exit 1;done
View Article
More Pages to Explore .....