在我的 Bash 脚本中出现错误:
./buildscriptbuild.sh: line 20: syntax error near unexpected token 'fi'
我已经在本地系统中测试了以下 bash 脚本。有人能在这方面帮助我吗?提前致谢。
#!/bin/sh
cd /home/ec2-user/inoutserver
if git pull origin development; then
if npm install; then
if grunt build --force; then
echo "build success"
else
if sudo cp -r dist/* /home/ec2-user/testfolder; then
echo "deployment success!"
fi
else
echo "deployment failed"
fi
else
echo "build failed"
fi
else
echo "npm install failed"
fi
答案1
在中间替换这个:
fi
else
echo "deployment failed"
经过 :
else
echo "deployment failed"
fi