You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Joachim Ansorg edited this page Nov 12, 2021
·
2 revisions
Use [[ ]] or quote arguments to -v to avoid glob expansion.
Problematic code:
[ -v foo[0] ]
Correct code:
[ -v 'foo[0]' ]
Rationale:
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.