![]() |
Bash scripting problem with exit codes
Hi,
I'm having some problems with Bash shell scripting, here is my script: Code:
echo "exit code: ${?} [BEFORE]" Code:
exit code: 0 [BEFORE] My bash version: GNU bash, version 3.00.16(2)-release (i486-slackware-linux-gnu) Thanks for any help and I'm stumped on this one! Jeiku |
Well, there are two things I'd like to mention.
The $? variable is updated after every command. So, first it reflects the exit value from the perl script. Then, after the echo, $? is the exit value of the echo command. The if-statement references the echo command's exit value. To save it, you'll need to do something like this: Code:
#!/bin/bash |
Cool, thanks! I didn't realise that $? is updated after every command... doh! :)
|
All times are GMT -5. The time now is 02:56 PM. |