摘要:
先看一个例子:#!/bin/bashfun1(){ $1 if [ $? -ne 0 ] then echo Failed executing $1 exit 1 fi}fun2(){ echo $1# return 0 or 1}fun1 "fun2 \"that is right\""输出结果为:"that我们期待的结果应该为:that is right为什么会这样呢?实际上,例子中实际调用fun1()时,$1为fun2 \"that is right\",因此fun2()中的$1就成了"that。使用eval 阅读全文