Number greater than 255 in bash shell script
bash, shell
Solution
In bash, `return` does not do what you expect it does from other programming languages:
The return value of a simple command is its exit status, or 128+n if the command is terminated by signal n.
This code will work:
#!/bin/bash
function returnnumber(){
echo $1
}
returnnumber 256
Problem
How to return a number greater than 255 in ``` function returnnumber(){ x=256 return $x } returnnumber echo "value: $?" ``` I wanted to type 256 and 256 return But 256 return 0.