我无法弄清楚以下脚本有什么问题。
#!/bin/bash
if [ "$1" = "x" ]
then
echo Pushing web on sharada to origin.
else if [ "$1" = "y" ]
then
echo Pulling web on sharada from origin.
else
echo "Usage : arg x to push or y to pull."
fi
我在linux(Ubuntu)上xterm
.
你错过了最后关闭“fi”。
这else if
构造确实不是一个elif
延续,但取而代之的是新的if
生活在else
上一条的条款if
.
所以,正确格式化你应该有:
#!/bin/bash
if [ "$1" = "x" ]
then
echo Pushing web on sharada to origin.
else
if [ "$1" = "y" ]
then
echo Pulling web on sharada from origin.
else
echo "Usage : arg x to push or y to pull."
fi
fi # <-- this closes the first "if"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)