在zsh
脚本中,
echo ${X:-4711}
输出变量X的值,如果没有则输出4711。
echo ${X:u}
输出变量X的值,转换为大写。
我想知道,是否有办法将两者结合起来,即具有
的效果tmp=${X:-4711}
echo $X:u
不引入辅助变量。
答案 0 :(得分:3)
{{1}}
来自{{1}}:
If a `${...}` type parameter expression or a `$(...)` type command substitution is used in place of name above, it is expanded first and the result is used as if it were the value of name. Thus it is possible to perform nested operations: `${${foo#head}%tail}` substitutes the value of `$foo` with both 'head' and 'tail' deleted.