Skip to content

Latest commit

 

History

History
25 lines (15 loc) · 576 Bytes

SC2208.md

File metadata and controls

25 lines (15 loc) · 576 Bytes

Pattern: Unnecessary glob expansion with [

Issue: -

Description

With [, arguments will undergo glob expansion. If a file foo0 exists when the problematic code is run, it will check for the variable foo0 instead of the array entry foo[0]. If there additionally exists a foo1, it will simply fail with an error.

Use [[ ]] or quote the argument.

Example of incorrect code:

[ -v foo[0] ] 

Example of correct code:

[ -v 'foo[0]' ]

Further Reading