Skip to content

Files

Latest commit

 

History

History
25 lines (15 loc) · 633 Bytes

SC2175.md

File metadata and controls

25 lines (15 loc) · 633 Bytes

Pattern: Use of unquoted invalid brace expansion

Issue: -

Description

Using eval somecommand {1..$n} depends both on bash silently failing to interpret the brace expansion, and on it passing failing brace expansions literally.

Rather than depending on these questionable features (which already behave differently in other shells), use the explicit, predictable way of passing values literally: quoting.

Example of incorrect code:

eval echo {1..$n}

Example of correct code:

eval "echo {1..$n}"

Further Reading