我有一个简单的代码块似乎失败了,我不能 100% 确定为什么,
if ! -h /usr/sbin/gitploy; then
curl https://raw.githubusercontent.com/jeremyBass/gitploy/master/gitploy | sudo sh -s -- install
[ -h /usr/sbin/gitploy ] || echoerr "gitploy failed install"
else
gitploy gitploy_update
fi
失败了,但如果我这样做
[ -h /usr/sbin/gitploy ] || echoerr "gitploy failed install"
它本身工作得很好。我确信有一个简单的原因。有任何想法吗?
答案1
你这样做nested if
,所以你需要重新创建你的块,例如:
if [ ! -h /usr/sbin/gitploy ]; then
curl https://raw.githubusercontent.com/jeremyBass/gitploy/master/gitploy | sudo sh -s -- install
[ -h /usr/sbin/gitploy ] || echoerr "gitploy failed install"
else
gitploy gitploy_update
fi