分页: 1 / 1
为什么我的declare 指令在shell中是not found,但是在bash中却可以
发表于 : 2009-04-15 12:49
由 yutuer
shell中想用declare -i 来声明整形,但是老是说not found,但是在bash中却是正常的
Re: 为什么我的declare 指令在shell中是not found,但是在bash中却可以
发表于 : 2009-04-15 13:02
由 懒蜗牛Gentoo
那你说的在shell中可以是在哪个shell中?
Re: 为什么我的declare 指令在shell中是not found,但是在bash中却可以
发表于 : 2009-04-15 13:19
由 yutuer
就是自己写的一个脚本
#!/bin/bash
declare -i s=3*6;
echo $s;
奇怪的是,我用./文件名 是可以执行的,但是用sh 文件名,就会出现declare not found 的情况
Re: 为什么我的declare 指令在shell中是not found,但是在bash中却可以
发表于 : 2009-04-15 13:23
由 wangdu2002
应该是路径设置问题。
Re: 为什么我的declare 指令在shell中是not found,但是在bash中却可以
发表于 : 2009-04-15 13:25
由
Re: 为什么我的declare 指令在shell中是not found,但是在bash中却可以
发表于 : 2009-04-15 13:29
由 yutuer
应该是的把,ls了一下
lrwxrwxrwx 1 root root 4 2009-03-21 07:55 /bin/sh -> dash
这样的
Re: 为什么我的declare 指令在shell中是not found,但是在bash中却可以
发表于 : 2009-04-15 13:44
由 yutuer
同样,我直接使用 /bin/sh 文件名,也是not found
Re: 为什么我的declare 指令在shell中是not found,但是在bash中却可以
发表于 : 2009-04-15 14:16
由 xhy
yutuer 写了:应该是的把,ls了一下
lrwxrwxrwx 1 root root 4 2009-03-21 07:55 /bin/sh -> dash
这样的
dash不是bash 差别太大了
Re: 为什么我的declare 指令在shell中是not found,但是在bash中却可以
发表于 : 2009-04-15 16:18
由 yutuer
那怎么样改才能让我能用sh 文件名
来执行shell脚本呢?
Re: 为什么我的declare 指令在shell中是not found,但是在bash中却可以
发表于 : 2009-04-15 16:26
由 xhy
yutuer 写了:那怎么样改才能让我能用sh 文件名
来执行shell脚本呢?
把指向dash的sh改成指向bash
Re: 为什么我的declare 指令在shell中是not found,但是在bash中却可以
发表于 : 2009-04-15 16:44
由 yutuer
好了,谢谢xhy
那为什么sh最开始会是指向dash的呢?
还有,我开始不是加了#!/bin/bash吗,有什么用处阿
Re: 为什么我的declare 指令在shell中是not found,但是在bash中却可以
发表于 : 2009-04-15 17:50
由 xhy
yutuer 写了:好了,谢谢xhy
那为什么sh最开始会是指向dash的呢?
还有,我开始不是加了#!/bin/bash吗,有什么用处阿
如果你用sh xxx的命令执行,那么第一行的 #!/bin/bash 就被无视了
如果是 chmod +x xxx.sh
再用 ./xxx.sh执行 shell会分析文件的首行,根据那个调用解释器
Re: 为什么我的declare 指令在shell中是not found,但是在bash中却可以
发表于 : 2009-04-17 13:47
由 yutuer
xhy 写了:yutuer 写了:好了,谢谢xhy
那为什么sh最开始会是指向dash的呢?
还有,我开始不是加了#!/bin/bash吗,有什么用处阿
如果你用sh xxx的命令执行,那么第一行的 #!/bin/bash 就被无视了
如果是 chmod +x xxx.sh
再用 ./xxx.sh执行 shell会分析文件的首行,根据那个调用解释器
彻底明白了,太谢谢鸟
Re: 为什么我的declare 指令在shell中是not found,但是在bash中却可以
发表于 : 2009-05-24 13:20
由 luber
修改 sh 的命令 sudo dpkg-reconfigure dash/bash