Does bash support variable substitution in return
statement?
From man bash
:
return [n]
Causes a function to stop executing and return the value specified by n to its caller.
Is n
allowed to be a variable substitution?
I tested on the following example:
$ cat t345.sh
f()
{
local x=13
return $x
}
f
echo $?
$ bash t345.sh
13
$ bash --version
GNU bash, version 5.2.21(1)-release (x86_64-pc-cygwin)
Here we see that Bash doesn't complain about return $x
and f
returns 13.
Was it linke this all the time OR since which version Bash started supporting this?