Created SC2151 (markdown)

koalaman
2015-02-14 12:03:27 -08:00
parent ac250dc75b
commit 883b63c41d

27
SC2151.md Normal file

@@ -0,0 +1,27 @@
## Only one integer 0-255 can be returned. Use stdout for other data.
### Problematic code:
myfunc() {
return foo bar
}
### Correct code:
myfunc() {
echo foo
echo bar
return 0
}
### Rationale:
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.
See [[SC2152]] for more information.
### Exceptions:
None