Skip to content

Files

Latest commit

 

History

History
31 lines (21 loc) · 667 Bytes

SC2041.md

File metadata and controls

31 lines (21 loc) · 667 Bytes

Pattern: Use of '..' to run as a command

Issue: -

Description

The intent was to run the code in the single quotes. This would have worked with slanted backticks, `..`, but here the very similar looking single quotes '..' were used, resulting in a string literal instead of command output.

This is one of the many problems with backticks, so it's better to use $(..) to expand commands.

Example of incorrect code:

for i in 'seq 1 10'
do
  echo "$i"
done

Example of correct code:

for i in $(seq 1 10)
do
  echo "$i"
done

Further Reading