/ usr / bin / copycat:第77行:意外的文件结束?

时间:2013-12-07 00:56:22

标签: shell unix ubuntu scripting terminal

我在为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

1 个答案:

答案 0 :(得分:2)

您没有fi与第57行的if相匹配。

正确缩进代码可以更容易地找到这样的错误。

(顺便说一句,在/usr/bin中安装实验性脚本可能不是一个好主意,这是用于系统二进制文件。安装在$PATH的其他目录中,也许是$HOME/bin - 或者只需将它们放在当前目录中,然后键入./script-name即可运行它们。)