现在的位置: 首页 > 综合 > 正文

Ubuntu的shell之bash和dash

2019年07月18日 ⁄ 综合 ⁄ 共 1234字 ⁄ 字号 评论关闭

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。
但这样将丧失脚本的通用性,使其在不具备所指定脚本的系统下不能被执行。

抱歉!评论已关闭.