我想回显包含函数参数的变量,例如:<svg width=0 height=0>
<defs>
<clipPath id="shape--start">
<polygon points="0,100 22.222,133.333 8.333,147.222 -13.889,113.889 -47.222,91.667 -33.333,77.778">
<animate attributeType="XML" attributeName="points"
from="0,100 22.222,133.333 8.333,147.222 -13.889,113.889 -47.222,91.667 -33.333,77.778"
to="144.444,-44.444 166.667,-11.111 152.778,2.778 130.556,-30.556 97.222,-52.778 111.111,-66.667"
dur="2s" repeatCount="indefinite"/>
</polygon>
</clipPath>
</defs>
</svg>
<div class="box">
</div>
脚本如下:
echo ${str1_$1_str2}
当我执行shell脚本时,错误提示:
func_test () {
eval str1_$1_str2=sucker
echo ${str1_$1_str2}
}
func_test 1
出什么问题了?
答案 0 :(得分:2)
间接参数扩展可能会有所帮助:
func_test(){
declare str1_$1_str2="foobar"
local x="str1_${1}_str2"
echo "${!x}"
}
func_test 222
输出:
foobar