From 0b21e8dd9ba1952baa5eddc3fa9890fe45ae8959 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Fri, 27 Apr 2018 22:22:21 -0700 Subject: [PATCH] Created SC1131 (markdown) --- SC1131.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 SC1131.md diff --git a/SC1131.md b/SC1131.md new file mode 100644 index 0000000..8386c8e --- /dev/null +++ b/SC1131.md @@ -0,0 +1,38 @@ +## Use `elif` to start another branch. + +### Problematic code: + +```sh +if false +then + echo "hi" +elseif true +then + echo "ho" +fi +``` + +### Correct code: + +```sh +if false +then + echo "hi" +elif true +then + echo "ho" +fi +``` +### Rationale: + +ShellCheck noticed that you appear to be using `elseif` or `elsif` as a keyword. This is not valid. + +`sh` instead uses `elif` as its alternative branch keyword. + +### Exceptions: + +If you have made your own function called `elseif` and intend to call it, you can ignore this message. + +### Related resources: + +* Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc! \ No newline at end of file