From 883b63c41dfe0cc981bfd023c8c633dec3f3f8f4 Mon Sep 17 00:00:00 2001 From: koalaman Date: Sat, 14 Feb 2015 12:03:27 -0800 Subject: [PATCH] Created SC2151 (markdown) --- SC2151.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 SC2151.md diff --git a/SC2151.md b/SC2151.md new file mode 100644 index 0000000..5128543 --- /dev/null +++ b/SC2151.md @@ -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 \ No newline at end of file