strange bash #?
Kurt Wall
kwall
Mon May 17 12:00:21 PDT 2004
In a 0.5K blaze of typing glory, M.W. Chang wrote:
> #!/bin/bash
> tar
> echo $?
> if [ $? == 0 ]
> then
> echo "zero"
> else
> echo "not zero"
> fi
>
> It didn't work. $? was 2, but it still printed "zero". Why?
> is $? a number or a string?
Because "$?" holds the return value of the last executed command,
which is, in this case, the "echo $?" command. Remove the "echo $?"
line and see what happens.
Kurt
--
"And what will you do when you grow up to be as big as me?"
asked the father of his little son.
"Diet."
More information about the Linux-users
mailing list