basically I have written a shell script for a homework assignment that works fine however I am having issues with exiting. Essentially the script reads numbers from the user until it reads a negative number and then does some output. I have the script set to exit and output an error code when it receives anything but a number and that's where the issue is.
The code is as follows:
if test $number -eq $number >dev/null 2>&1
then
"do stuff"
else
echo "There was an error"
exit
The problem is that we have to turn in our programs as text files using script and whenever I try to script my program and test the error cases it exits out of script as well. Is there a better way to do this? The script is being run with the following command in the terminal
script "insert name of program here"
Thanks
script "insert name of program here"isn't very helpful. Isscriptin this case the externalscriptcommand? Is it the outer test script, whereinsert name of program hereis the name of the inner script under test? If so, how is the test script invoking the program under test?