Problem with exit command
Hi,
I am executing script written by other user. I am executing script A.ksh, and A.ksh calls B.ksh. But It is giving error: /home/user/B.ksh[132]: exit: -1: unknown option When I checked B.ksh It has following lines of code if [ $success = 0 ] then ... some action ... else ... some action ... exit -1 fi I am new to linux, Can you please help me? Thank you |
Hi.
Unix exit status codes have to be in the range 0-255, so -1 is out of range. I'd probably just change it to '1'. Dave |
I agree with Dave. Typically, '-1' is meant to set all bits to 1 to flag a general error condition. Exiting with '255' would be probably be a better direct translation, but unless some other process is checking for a specific return value, anything other than zero would suffice.
|
|
I agree. However it should not give an error, but it should translate it to 255. The problem is that it interprets the value -1 as an option. Eventually you can try
Code:
exit -- -1 |
[$success = 0]
The code always goes to else part and runs " exit -1". |
The above advice is correct.
In a addition, the code you've shown does not set success to anything, so the condition will fail, as it does. Strictly speaking (as you seem to be doing a numerical comparison), the syntax is Code:
if [[ $success -eq 0 ]] |
All times are GMT -5. The time now is 08:43 AM. |