日安
我在我自己的debian笔记本上测试shell脚本
android-verify.sh: line 14: syntax error near unexpected token `then'
android-verify.sh: line 14: `if [[ ! -z $iopt ]] then { wd=$(pwd) basename "$(test -L "$0" && readlink "$0" || echo "$0")" > /tmp/scriptname'
我还是新来的。请告知。
当尝试包含;
时
在以下说明中
if [[ ! -z $iopt ]]**;** then { wd=$(pwd) basename "$(test -L "$0" && readlink "$0" || echo "$0")" > /tmp/scriptname
scriptname=$(echo -e -n $wd/ && cat /tmp/scriptname); su -c "cp $scriptname /usr/bin/monitor" root && echo "Congratulations! Script Installed, now run monitor Command" || echo$
fi
这个bash终端返回以下消息
android-verify.sh: line 17: syntax error near unexpected token `fi'
android-verify.sh: line 17: `fi '
1条答案
按热度按时间kuhbmx9i1#
下面是修改后的代码,以解决问题并使其更具可读性:
then
之前需要一个分号,这是正确的。wd
变量中,base
之前没有分号,因此wd
变量实际上只为base
命令设置,而不是任何后续命令。所以总结一下:
if
测试和then
语句之间添加“;”wd
和base
之间添加“;”或换行符echo$
更改为echo
希望能帮上忙。