bash - source a shell script from another script and check return code -


i want source file eg name.sh script , check return code , decide on it's error code. if use

source name.sh 

then if name.sh return non-zero return code main script stop run need decide on exit code weather continue or stop.

if use

ret_code="`source name.sh`" echo $ret_code 

then ret_code null , no error code printed. can't use these:

sh name.sh ./name.sh bash name.sh 

because name.sh not executable , don't want executable

file not need executable run sh name.sh. use $?.

sh name.sh ret_code=$? 

Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -