我脚本如下:
#!/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”是输入的两数
本人刚学的,有好多不懂,望高手指点!!
[问题]为什么我的shell在ubuntu 7.10下运行会有错误
-
- 帖子: 34
- 注册时间: 2007-12-23 12:22
- BigSnake.NET
- 帖子: 12522
- 注册时间: 2006-07-02 11:16
- 来自: 廣州
- 联系:
- bones7456
- 帖子: 8495
- 注册时间: 2006-04-12 20:05
- 来自: 杭州
- 联系: