简体   繁体   English

在bash阵列上取消设置命令:手册中提到的路径名扩展和副作用

[英]Unset command on bash arrays: pathname expansion and side effects mentioned in the manual

I saw this statement in the bash manual and wasn't sure how to connect the unset command, pathname expansion and side-effects. 我在bash手册中看到了该语句,并且不确定如何连接unset命令,路径名扩展和副作用。

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: 因此,如果您有一个像avar1这样的文件,那么它将尝试取消设置avar1

unset avar[12]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM