Pattern: Use of keyword as literal
Issue: -
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"
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.