I have created this script in order to find exit codes for some arguments I need to test. Now I need to make a second script that calls this script to check for exit codes. However the 2nd script needs to read the exit code from this script and then assign text to it.
example:
passing /etc/resolve.conf
then using echo $?
returns 0
now i want something like found file
to echo.
This is the first script to find exit codes
#/bin/bash
shopt -s -o nounset
if [ $# != 1 ]; then
exit 2
fi
if [[ ${1:0:1} = /* ]]; then
:
else
exit 3
fi
if [ -f ${1} ]; then
exit 0
else
exit 1
fi
This is where I am at with my second script. After ./script1.sh is called, I don't understand how to set the exit code 0 to = text.
#/bin/bash
shopt -s -o nounset
./script1.sh
I know it would be easier to include echos in script1 like this example but in this case they need to be read from a second file.
if [ -f ${1} ]; then
echo "file found"
exit 0
else
echo "file not found"
exit 1
fi