I have a bash script method that returns the input value as such. The return value however, is always the value modulo 256. I googled for a while and found this article that said it's always modulo 256 (something I'd already guessed), but didn't explain why. Can someone shed some light on why it does this?
var=$1
hello () {
return $var
}
hello
ret=$?
echo $ret
>>> ./script 300
>>> 44
The return value is limited to 1 byte (8 bits). Taking the least significant byte from an integer is equivalent to modulo 256 (2^8).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With