在Zsh中,嵌套参数替换是可行的:
$ param=abc
# nested remove prefix ${...#a} and remove suffix ${...%c} =>
$ printf '%s\n' ${${param#a}%c}
# => b
在POSIX中有相应的等价物吗?
$ param=abc
$ printf '%s\n' ${${param#a}%c}
# => dash: 2: Bad substitution
# => sh: ${${param#a}%c}: bad substitution
# => bash: ${${param#a}%c}: bad substitution
eval
,具体取决于我的需求。 - Dummy00001bash
中没有起作用。 - benizi