Pattern: Use of literal {
or }
outside of quotes
Issue: -
If curly brackets don't appear alone at the start of an expression or as part of a parameter or brace expansion, the shell silently treats them as literals. This frequently indicates a bug, so ShellCheck warns about it.
Example of incorrect code:
rmf() { rm -f "$@" }
or
eval echo \${foo}
Example of correct code:
rmf() { rm -f "$@"; }
and
eval "echo \${foo}"
This error is harmless when the curly brackets are supposed to be literal, in e.g. awk {'print $1'}
. However, it's cleaner and less error prone to simply include them inside the quotes: awk '{print $1}'
.