Skip to content

Files

Latest commit

 

History

History
39 lines (24 loc) · 819 Bytes

SC1083.md

File metadata and controls

39 lines (24 loc) · 819 Bytes

Pattern: Use of literal { or } outside of quotes

Issue: -

Description

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}"

Exceptions

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}'.

Further Reading