문제

I saw this statement in the bash manual and wasn't sure how to connect the unset command, pathname expansion and side-effects.

The unset builtin is used to destroy arrays. unset name[subscript] destroys the array element at index subscript. Care must be taken to avoid unwanted side effects caused by pathname expansion.

Is there an example that illustrates the sort of side effect paired with pathname expansion that this manual is talking about?

도움이 되었습니까?

해결책

It means you have to quote it:

unset 'avar[index]'
unset "avar[$index]"
unset 'avar[1234]'

[] are also valid patterns for pathname expansion

So if you have a file like avar1, this would try to unset avar1 instead:

unset avar[12]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top