non-zero value of 2 numbers with a return exit code in shell
So here's my situation. I want to be able to exit RC/RC1 which has a non-zero value. When the below code is executed if RC is 0 RC1 is returned with a non-zero exit code(best case scenario) if RC is non-zero and RC1 is also non-zero i will miss exit code of RC1(meaning i will not be able to use RC1's exit code). How can i send the right exit code? In essence i would like to email the non-zero variable if [ $RC -ne 0 ] || [ $RC1 -ne 0 ]; then if [ $RC -ne 0 ]; then exit $RC else exit $RC1 fi
You want to return two exit codes at the same time? I guess that, when driving a car, you also want to sit on the front seat and on the back seat at the same time. You can do it, but you need a special car for this. Here are two ideas for making such a car: If you know that in this context each exit code must be a 1-digit number, you could return something like $((RC*10+RC2)) - I'm using bash/zsh syntax here, as you didn't say which shell you are using. If necessary, you have to adapt this to your shell. You could adapt the interface of your script, by printing something like "$RC1 $RC2" to stderr if at least one of them is non-zero, i.e.: if [ $RC -ne 0 ] || [ $RC1 -ne 0 ]; then echo "$RC $RC1" 1>&2 exit 1 else exit 0 fi In both cases, the calling process has to take apart the combined exit code to get back the original ones.
Shell Script extracting particular path from given path
change multiple shell commands into one in groovy
shell script to print and sort the date column in csv
Split large gzip file while adding header line to each split
Storing output of an executable with multi-line input to a variable in shell script
Syntax to read a file from while-do loop in shell script
Need to list Orgs and Spaces in Cloud Foundry
Adding a list of space separated numbers
Unset is not useful? (Korn shell)
what does #D mean in shell script
How to find paths matches a sub-string in a root directory recursively?
extracting fields from a file in Shell
How can I remove “^#” char from a file?
How to replace line in file below text pattern
Unix - question mark / special character on filename after create file [duplicate]
Add a column in output of a command through Shell Script