如何将脚本从 bash 迁移到 dash?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4759731/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 23:19:24  来源:igfitidea点击:

How to migrate scripts from bash to dash?

bashdash-shell

提问by dugres

I'd like to avoid installing bash on every new Debian 6 install. So I need to convert all my bash scripts to dash.
- How would you do that ?
- What are the differences between the 2 languages ?
- Are you aware of any caveat and pitfall ?
- Is it possible to automate that task ?

我想避免在每个新的 Debian 6 安装中安装 bash。所以我需要将我所有的 bash 脚本转换为 dash。
- 你会怎么做?
- 两种语言之间有什么区别?
- 你知道任何警告和陷阱吗?
- 是否可以自动执行该任务?

采纳答案by Paused until further notice.

Here is a page that shows some Bashisms. You can use it as a guide for porting from Bash to Dash.

这是一个显示一些 Bashisms 的页面。您可以将其用作从 Bash 移植到 Dash 的指南。

I don't know why you say you need to install Bash. It's listed as an essential package.

我不知道你为什么说你需要安装Bash。它被列为必不可少的包

回答by Roman Cheplyaka

The best strategy is to stick to the standardinstead of any particular implementation. Dash is much closer to it than Bash.

最好的策略是坚持标准而不是任何特定的实现。Dash 比 Bash 更接近它。

You might try Lokerto get some assistance. If you are interested in it or have any problems, feel free to bother me by email.

您可以尝试使用Loker来获得一些帮助。如果您对此感兴趣或有任何问题,请随时通过电子邮件打扰我。

There are some other toolsas well.

还有一些其他的工具