From f79accb59c2a3c2dda620d3164d0784b26e542ed Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Sat, 24 Nov 2018 22:59:06 -0800 Subject: [PATCH] Created SC2241 (markdown) --- SC2241.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 SC2241.md diff --git a/SC2241.md b/SC2241.md new file mode 100644 index 0000000..43c394d --- /dev/null +++ b/SC2241.md @@ -0,0 +1,27 @@ +## The exit status can only be one integer 0-255. Use stdout for other data. + +### Problematic code: + +```sh +exit foo bar +``` + +### Correct code: + +```sh +echo foo +echo bar +exit +``` + +### Rationale: + +In bash, `exit` can only be used to signal success or failure (0 = success, 1-255 = failure). + +To exit with textual or multiple values from a function, write them to stdout and capture them with command substitution instead. + +See [[SC2242]] for more information. + +### Exceptions: + +None