Skip to content

Latest commit

 

History

History
24 lines (15 loc) · 523 Bytes

SC2257.md

File metadata and controls

24 lines (15 loc) · 523 Bytes

Pattern: Use of arithmetic expression that modifies variable

Issue: -

Description

You are using an arithmetic expression that modifies a variable, e.g. $((x+=1)) or $((x++)), in the name of a file to redirect from/to, in a here document, or in a here string.

Example of incorrect code:

curl "$URL" > "image$((i++)).jpg"

Example of correct code:

i=$((i+1))
curl "$URL" > "image$i.jpg"

Further Reading