bash脚本错误 Syntax error: else unexpected (expecting then)解决

今天在使用 bash 脚本发布程序时,发生了这样的错误

1
xxx.sh: Syntax error: "else" unexpected (expecting "then")

到处搜索资料尝试无果之后想到会不会是编码问题导致,
dos2unix 处理后测试果然可以

1
sudo apt-get -y install dos2unix

处理

1
2
dos2unix xxx.sh
dos2unix: converting file xxx.sh to Unix format ...

欢迎关注我的其它发布渠道