【发布时间】:2013-12-24 12:42:21
【问题描述】:
我在为 Cydia 制作的 bash 脚本中遇到该错误。但是我的文件以 76 结尾。
这是我的第一个实际脚本,所以我只是在搞乱,但想知道错误。
谢谢!
P.S:我在 Ubuntu 13.10 的 gedit 中对此进行编码
#!/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
【问题讨论】:
-
下次的一些建议:在问题中包含您的源代码(此站点上的问题可能会持续存在并且有用多年,并且取决于 pastebin.com 不是一个好主意;它也更少方便的)。并尝试将您的代码精简为仍然重现问题的较小示例;例如,您可以删除
echos 和tease函数。推荐阅读:sscce.org
标签: shell unix ubuntu scripting terminal