分页: 1 / 1

[问题]为什么我的shell在ubuntu 7.10下运行会有错误

发表于 : 2008-04-23 13:57
sharpshootor
我脚本如下:
#!/bin/sh
echo "Input two interger number:"
foo=0
bar=0
declare -i foo
declare -i bar
read foo bar
select opsign in "+" "-" "*" "/" "exit"
do
break
done
if [[ $opsign = "exit" ]] ;then
exit 0
fi
if [[ $opsign = '/' && $bar = 0 ]] ;then
echo "divisor should not be 0"
exit 1
fi
echo "${foo}${opsign}${bar}=$(($foo $opsign $bar))"

exit 0
以上脚本我在windows下虚拟机redhat 9.0,运行没有任何问题,为什么同样的代码,我在ubuntu7.10(实机)下却出现如下错误:
yang@yang-desktop:~/test/finish$ ./cal.sh
Input two interger number:
./cal.sh: 5: declare: not found
./cal.sh: 6: declare: not found
1 2
./cal.sh: 8: select: not found
./cal.sh: 9: Syntax error: "do" unexpected
yang@yang-desktop:~/test/finish$
其中的“1 2”是输入的两数
本人刚学的,有好多不懂,望高手指点!!

发表于 : 2008-04-23 14:02
BigSnake.NET
安装bash, 卸掉dash

发表于 : 2008-04-23 14:31
bones7456
dash害死多少人啊...不知道为什么ubuntu会用它.唉

发表于 : 2008-04-23 16:08
thword
#!/bin/sh
改成
#!/bin/bash