shell


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.

Related Links

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

Categories

HOME
google-cloud-platform
facebook-oauth
jpa
checkstyle
fpga
google-spreadsheet
ns-3
depth
zend-framework
devise
entity-framework-core
rom
x264
google-cloud-datalab
flume
barcode
teechart
accessibility
octave
android-securityexception
mod-security
google-form
nancy
pybossa
shared-libraries
dimensional-modeling
html5-appcache
topology
drive
breadth-first-search
resourcebundle
direct3d11
jquery-multiselect
wcag
constexpr
dotspatial
powershell-ise
cognos-bi
kodi
jmockit
hibernate-validator
code-snippets
html-encode
browser-extension
lubridate
diacritics
ogc
levenshtein-distance
apollostack
apache-spark-dataset
servermanager
flask-restful
tinymce-3
tf
convex-optimization
lightning
video-conferencing
filenet
juice-ui
polyline
vulcanize
resourcemanager
embedding
freepbx
yajsw
blitline
design-principles
mobiledoc-kit
phpgrid
ascii-art
morton-number
evolus-pencil
typemock
java-security
code-documentation
mobility
build-script
codeplex
xml-dsig
android-framework
conditionaltagsupport
scriptaculous
scringo
nevron
facebook-timeline
mysql-error-2013
intersect
fragmenttransaction
faye
cuda-gdb
gobject-introspection
fsevents
timthumb
folding
feasibility
sun
perl5.12
flvplayback
product-management
great-circle

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile