Bash return values ($?)
Johnny Rosenberg
gurus.knugum at gmail.com
Wed Oct 2 19:21:49 UTC 2013
I am experimenting a little with C. I wrote a small application that
returns an integer value. The value can be any integer value, even negative.
However, when checking $? after running it, when my application returns -1,
$? is 255. Is there a way to get around this? Some setting somewhere,
perhaps?
I want to run my application from a script and then check for [ $? < 0 ]
and things like that, but I can't do that if -1 is ”translated” to 255…
Someone compiled and tested my application in Windows (I don't have Windows
myself) and he said that e correct values (-1, for instance) was detected
by the shell.
Seems like Bash chop the return value to 8 bits unsigned int. Is this a
Bash thing or does this happen with the other shells (zsh, ksh, tcsh etc.)
as well?
Johnny Rosenberg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20131002/dc9b4fad/attachment.html>
More information about the ubuntu-users
mailing list