Skip to content

Files

Latest commit

 

History

History
27 lines (16 loc) · 715 Bytes

SC2184.md

File metadata and controls

27 lines (16 loc) · 715 Bytes

Pattern: Use of unset with unquoted argument

Issue: -

Description

Arguments to unset are subject to regular glob expansion. This is especially relevant when unsetting indices in arrays, where [..] is considered a glob character group.

Example of incorrect code:

unset foo[index]

Having a file called food in the current directory will result in unset foo[index] expanding to unset food, which will silently succeed without unsetting the element.

Quoting so that the [..] is passed literally to unset solves the issue.

Example of correct code:

unset 'foo[index]'

Further Reading