Ubuntu的shell之bash和dash

The installer has detected that your system uses the dash shell
as /bin/sh.  This shell is not supported by the installer.
You can work around this problem by changing /bin/sh to be a
symbolic link to a supported shell such as bash.
For example, on Ubuntu systems, execute this shell command:
   % sudo dpkg-reconfigure -plow dash
   Install as /bin/sh? No
Please refer to the Getting Started guide for more information,
or contact CodeSourcery Support for assistance.

今天在安装Codesourcery的过程中Terminate 报出上述的错误,百度后得到如下链接的真传:

http://hi.baidu.com/gaogaf/item/6de26f15f779663eb8318046

Ubuntu的 shell 默认安装的是 dash,而不是 bash。
运行以下命令查看 sh 的详细信息,确认 shell 对应的程序是哪个:
$ls -al /bin/sh

sanwu备注:命令选项-al是-a 和 -l的合并,-a的含义是all,-l的含义是较长格式列出信息

(sanwu备注:对于本机相应如下:

hust_smartcar@hustsmartcar:~$ ls -al /bin/sh
lrwxrwxrwx 1 root root 4 10月 10 13:19 /bin/sh -> dash


dash 比 bash 更轻,更快。但 bash 却更常用。
如果一些命令、脚本等总不能正常执行,有可能是 dash 的原因。
比如编译 Android 源代码的时候,如果使用 dash,则有可能编译出错,或者编译的系统不能启动。

通过以下方式可以使 shell 切换回 bash:
$sudo dpkg-reconfigure dash   (sanwu注:dpkg用法见百度百科

http://baike.baidu.com/link?url=yF3D6yeTB7jY_YvTlxe3RgupdPbIeUnhrvPwzuu9375Wa4g_S8EsTO2jOD0WKJpZfxR3IdyM2Qxy1YL8lsLlJq


然后选择 no 或者 否 ,并确认。
这样做将重新配置 dash,并使其不作为默认的 shell 工具。

也可以直接修改 /bin/sh 链接文件,将其指定到 /bin/bash:
$sudo ln -fs /bin/bash /bin/sh

还有一种解决方法是,在脚本文件中直接指定使用的 shell,而不是指定 sh:
例如使用 #!/bin/bash 或者 #!/bin/dash 而不是#!/bin/sh。
但这样将丧失脚本的通用性,使其在不具备所指定脚本的系统下不能被执行。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值