这是另一个无法搜索的问题:如何解释$+commands[foobar]
?我假设它是 的变体$commands[foobar]
,但谁知道呢。(使用 zsh,至少我永远不知道。)
我还想知道如何在 zsh 文档或在线搜索这个问题的答案。
${+name}
If name is the name of a set parameter ‘1’ is substituted, otherwise ‘0’
is substituted.
Run Code Online (Sandbox Code Playgroud)
例子:
$ unset foo
$ if (( $+foo )); then echo set; else echo not set; fi
not set
$ foo=1
$ if (( $+foo )); then echo set; else echo not set; fi
set
Run Code Online (Sandbox Code Playgroud)
在 中$+commands[foobar]
,zsh
检查名称 return by$commands[foobar]
是否为设置参数。
归档时间: |
|
查看次数: |
1458 次 |
最近记录: |