The return code from the process is limited to 8 bits (the remaining bits have meta-information like โwas there a core of the dump?โ And โdid it signal to kill the process?โ), So you wonโt be able to use this to get values โโthat exceed 255 .
Thus, all values โโwill be modulo 256.
16^2 = 256 % 256 = 0 17^2 = 289 % 256 = 33 18^2 = 324 % 256 = 68 : 22^2 = 484 % 256 = 228 23^2 = 529 % 256 = 17
Instead, try to capture the output, not the return code:
#!/bin/bash square() { let "res=$1*$1" echo $res
source share