在阅读了bash手册页并针对此帖子之后。
我仍然很难理解该eval命令的确切功能以及它的典型用法。例如,如果我们这样做:
bash$ set -- one two three # sets $1 $2 $3
bash$ echo $1
one
bash$ n=1
bash$ echo ${$n} ## First attempt to echo $1 using brackets fails
bash: ${$n}: bad substitution
bash$ echo $($n) ## Second attempt to echo $1 using parentheses fails
bash: 1: command not found
bash$ eval echo \${$n} ## Third attempt to echo $1 using 'eval' succeeds
one
这里到底发生了什么,美元符号和反斜杠如何与问题联系在一起?
FFIVE