SH与BASH的区别?
-
- 帖子: 6
- 注册时间: 2007-08-27 5:16
SH与BASH的区别?
#!/bin/bash
#计算
#时间2008/03/08
declare -i a=5
declare -i b=3
declare -i c=$a+$b
echo $c
为什么这个脚本
用sh xxx.sh执行会
test2.sh: 5: declare: not found
test2.sh: 6: declare: not found
test2.sh: 7: declare: not found
而非得用bash xxx.sh才能执行?
#计算
#时间2008/03/08
declare -i a=5
declare -i b=3
declare -i c=$a+$b
echo $c
为什么这个脚本
用sh xxx.sh执行会
test2.sh: 5: declare: not found
test2.sh: 6: declare: not found
test2.sh: 7: declare: not found
而非得用bash xxx.sh才能执行?
- xiehuoli
- 帖子: 5941
- 注册时间: 2006-06-10 8:43
- 来自: 中国 CS
- leeaman
- 帖子: 30702
- 注册时间: 2007-02-02 18:14
- 系统: debian sid
- BigSnake.NET
- 帖子: 12522
- 注册时间: 2006-07-02 11:16
- 来自: 廣州
- 联系:
- millenniumdark
- 论坛版主
- 帖子: 4159
- 注册时间: 2005-07-02 14:41
- 系统: Ubuntu 14.04 (Kylin)
- 联系:
Re: SH与BASH的区别?
不是告訴你了嗎?bash纔支持declare,你的sh(估計是dash吧)不支持orlose 写了:
为什么这个脚本
用sh xxx.sh执行会
test2.sh: 5: declare: not found
test2.sh: 6: declare: not found
test2.sh: 7: declare: not found
而非得用bash xxx.sh才能执行?
-
- 帖子: 1
- 注册时间: 2009-08-07 13:09
Re: SH与BASH的区别?
ubuntu好像从6.x起就连接到 dash 了phpknows 写了:现在基本上sh链接到bash
csh连接到tcsh
- 懒蜗牛Gentoo
- 论坛版主
- 帖子: 7353
- 注册时间: 2007-03-02 17:36
- 系统: Linux Mint
Re:
那只是默认情况下,也就是你直接运行这个脚本,他会用bash解释。orlose 写了:#!/bin/bash
不是已经说明是使用的是BASH了么?
但是你sh xxx.sh就是再说,就非要用系统默认的shell运行,不管那行什么#!/bin/bash的鬼东西。而ubuntu目前默认的是dash,所以出问题……
虽然世上没有完美的东西,但这并不影响我们追求完美,因为只有偏执狂才TMD能成功。
10.04新手入门——笨兔兔讲述自己的故事
10.04新手入门——笨兔兔讲述自己的故事
- bones7456
- 帖子: 8495
- 注册时间: 2006-04-12 20:05
- 来自: 杭州
- 联系:
-
- 帖子: 158
- 注册时间: 2007-11-10 11:15
Re: SH与BASH的区别?
dash到底如何啊?