尝试编写一个 bash,其中要使用的命令在环境变量中指定(如果已定义)。这样做如下:
if [ -z $MY_DIFF ];
then
echo Using standard diff $(which diff), change MY_DIFF env variable to use a different one.
echo $(which diff)
$diffv=$(which diff)
else
$diffv=$MY_DIFF
fi
$diffv c.xml c2.xml
但我得到:
./bash.sh: line 10: =/opt/gnu/bin/diff: No such file or directory
./bash.sh: line 13: c.xml: command not found
我确定该文件存在并且我确实有权执行。知道问题可能是什么吗?