Skip to content

Files

Latest commit

 

History

History
40 lines (24 loc) · 810 Bytes

SC1010.md

File metadata and controls

40 lines (24 loc) · 810 Bytes

Pattern: Use of keyword as literal

Issue: -

Description

done, then, do, fi and esac only work as a keyword when they are the first token of the command. If added after a command, it will just be the literal word.

Example of incorrect code:

for f in *; do echo "$f" done

or

echo $f is done

Example of correct code:

for f in *; do echo "$f"; done

or

echo "$f is done"

Exceptions

If you're intentionally using done as a literal, you can quote it to make this clear to ShellCheck (and also human readers), e.g. instead of echo Task is done, use echo "Task is done". This makes no difference to the shell, but it will silence this warning.

Further Reading