Updated SC1010 (markdown)

Vidar Holen
2021-07-02 08:43:31 -07:00
parent c4ca104491
commit 8eb8f048fd

@@ -1,5 +1,7 @@
## Use semicolon or linefeed before 'done' (or quote to make it literal). ## Use semicolon or linefeed before 'done' (or quote to make it literal).
(or `do` `then`, `fi`, `esac`)
### Problematic code: ### Problematic code:
``` ```
@@ -26,9 +28,9 @@ echo "$f is done"
### Rationale: ### Rationale:
`done` only works as a keyword when it's the first token of the command. If added after a command, it will just be the literal word "done". ShellCheck found a keyword like `done`, `then`, `fi`, `esac`, etc used as the argument of a command. This means that the shell will interpret it as a literal string rather than a shell keyword. To be interpreted as a keyword, it must be the first word in the line (i.e. after `;`, `&` or a linefeed).
This is also true for other keywords like `then`. In the example, `echo "$f" done` is the same as `echo "$f" "done"`, and the `done` does not terminate the loop. This is fixed by terminating the `echo` command with a `;` so that the `done` is the first word in the next line.
### Exceptions ### Exceptions