You could do a very simple script that checks if a parameter is passed and otherwise return 0
.
#!/bin/bash if [ $# -eq 1 ]; then # There's no parameter exit 0 else exit $1 fi
Give it execution permissions (chmod +x returnscript.sh
). Ways of invoking the script within a different script:
Way 1:
/path/to/returnscript.sh 100 retcode=$? # retcode = 100
Way 2:
/path/to/returnscript.sh retcode=$? # retcode = 0