这按预期工作: -
x="None of the specified ports are installed"
if [ "$x" = "None of the specified ports are installed" ];
then echo 1;
else echo 0;
fi
我得到1
了,这是我所期待的。
但这不起作用:-
y="`port installed abc`"
if [ "$y" = "None of the specified ports are installed" ];
then echo 1;
else echo 0;
fi
我得到0
了,这不是我所期望的;虽然
echo $y
给None of the specified ports are installed.
这里的主要区别是$y
由port installed abc
命令动态确定。但是为什么这会影响我的比较呢?