I have the following code snippet in my ksh script.
if [ $rc -ne 0 ]; then
print Error...
exit 1
fi
This block executes since I see the printed statement, but after the script, at the shell prompt, when I type echo $?
, the output I get is 0.
I think the code is not getting returned from the snippet mentioned. I have written below code and run in ksh . the output was as expected
ajay@pavilion:~$ cat ajay.ksh
var=1
if [ $var == 1 ]
then
print "Error"
exit 1
fi
output
ajay@pavilion:~$ ksh
$ ./ajay.ksh
Error
$ echo $?
1
$