Assuming I have this shell program :
foo.sh
#!/bin/sh
sum()
{
return 260
}
#main
sum
TMP=$?
echo$TMP
return $TMP
When running echo $?
I get only the first 8 bits of the returned number 260 : 100000100 => 00000100 => 4 .
Is there any explanation for this ?
Does this mean that my ubuntu supports only 8 bits ?
sum(){ echo 260; }; tmp=$(sum); echo $tmp
. Yes, this is much more awkward than in languages like C or Perl. – Oct 30 '20 at 01:22waitid()
instead of the historicalwait()
in order to collect all available information for the child. You can do this by using a modern shell like the recent Bourne Shell (bosh
) if you are on a POSIX compliant operating system. – schily Oct 30 '20 at 07:35waitid(2)
allows to retrieve the full exit status on Solaris, it does NOT on Linux, and no shell besides bosh is using it, anyways. Also, bosh is not installed by default on any system I know of. (I'm taking your word for bosh, I haven't yet tested it ;-)). – Oct 30 '20 at 21:05waitid()
works correctly on Solaris, UnixWare, FreeBSD, NetBSD and probably other OS. If other shells are on a state from the mid-1980s, this may cause a re-think about these shells. If Linux is not willing to fix kernel bugs, this should cause people users to re-think whether it is a good idea to use it. – schily Oct 30 '20 at 21:46