Pattern: Use of return
with multiple values
Issue: -
In bash, return
can only be used to signal success or failure (0 = success, 1-255 = failure).
To return textual or multiple values from a function, write them to stdout and capture them with command substitution instead.
Example of incorrect code:
somefunc() {
return foo bar
}
Example of correct code:
somefunc() {
echo foo
echo bar
return 0
}