我在为 Cydia 制作的 bash 脚本上遇到了这个错误。但是我的文件以 76 结尾。
这是我的第一个实际脚本,所以我只是在搞乱,但想知道错误。
谢谢!
P.S:我在 Ubuntu 13.10 的 gedit 中对此进行编码
http://pastebin.com/pj4pBDwB
#!/bin/bash
#Say Hello
#Check if they need help
if [ "$1" == "--help" ]; then
echo
echo "Usage: copycat <message>"
echo " --exit | Exit the script."
echo "CopyCat is a very simple script I have made for "
echo "practice & entertainment."
echo
exit 0
else
echo "===============/\===============/\==============="
echo "Hey, "$USER". I'm CopyCat! :) I have a tendency of "
echo "copying people..."
echo "Remember, at any time you can exit the script by "
echo "typing copycat --exit"
echo
fi
#Teaser
function tease(){
i=0
sleep 0.2
case "$i" in
'0')
echo "Teehee"
i=`expr $i + 1`
;;
'1')
echo "Your smart"
i=`expr $i + 1`
;;
'2')
echo "LOL Fool"
i=`expr $i + 1`
;;
'3')
echo "Isn't this getting old?"
i=`expr $i + 1`
;;
'4')
echo "Outta show off your brains, here!"
i=0
esac
}
#Copy them
RUN=true
i=0
echo "CopyCat: Let's Chat!"
read ans
if [ "$ans" != "--exit" ]; then
while [ RUN=true ]; do
i= `expr $i + 1`
read ans
sleep 0.5
echo "CopyCat: "$ans""
tease
echo
if [ $i -e 4 ]; then
echo "CopyCat: I am tired.. I am going to take a break..."
exit 0
fi
done
else
RUN=false
echo "CopyCat: Oh.. But we were having so much fun!"
exit 0
exit 0
最佳答案
你没有fi
匹配 if
在第 57 行。
正确缩进你的代码会更容易找到这样的错误。
(顺便说一下,在 /usr/bin
中安装实验脚本可能不是一个好主意,它用于系统二进制文件。安装在您的 $PATH
的其他目录中,也许是 $HOME/bin
- 或者只是将它们放在您的当前目录中通过键入 ./script-name
来运行它们。)
关于shell -/usr/bin/copycat : Line 77: unexpected end of file?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20436183/