达尔文/MacOS会修改Bash吗? [英] Does Darwin/MacOS modify Bash?

查看:62
本文介绍了达尔文/MacOS会修改Bash吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道使用Bash内置命令的Bash脚本的可移植性.

I'm wondering about the portability of Bash scripts that use Bash built-in commands.

我了解UNIX的每种形式都倾向于修改各种UNIX实用程序.但是他们倾向于不理会Bash和Bash的内置功能吗?尤其是MacOS呢?

I understand that each flavor of UNIX tends to modify various UNIX utilities. But do they tend to leave Bash and Bash built-ins alone? What about MacOS in particular?

推荐答案

据我所知,bash在Mac OS X上未经修改(除了需要对其进行细微调整外,您还可以在 http://opensource.apple.com/),脚本应该具有很好的可移植性.

As far as I know, bash is unmodified on Mac OS X (aside from minor tweaks required to make it compile; you can review the source on http://opensource.apple.com/), and scripts should be quite portable.

如Graham Lee& Gordon Davisson指出,Mac OS X附带了较旧的版本,并且受支持的版本之间存在差异. Bash 4具有关联数组和其他更改. Bash 3包括正则表达式匹配(可能还有其他我没有搜索过的匹配).记不住Bash 2的差异,也许还有些包围/条件测试的差异?

As Graham Lee & Gordon Davisson point out, Mac OS X ships with older versions and there are differences between supported versions. Bash 4 has associative arrays and other changes. Bash 3 includes regular expression matching (and probably others that I haven't searched for). Can't remember the Bash 2 differences, maybe some bracketing/conditional test differences?

Mac OS X 10.7.x Lion包含Bash3.2.x.我不记得确切的版本了,但是Mac OS X 10.6.x Snow Leopard& 10.5.x Leopard包括Bash3.x. Mac OS X 10.4.x Tiger和更早的版本使用Bash 2.0.5.因此,您肯定会在默认情况下遇到差异.

Mac OS X 10.7.x Lion includes Bash 3.2.x. I don't recall the exact versions off the top of my head, but Mac OS X 10.6.x Snow Leopard & 10.5.x Leopard include Bash 3.x. Mac OS X 10.4.x Tiger and earlier used Bash 2.0.5. So, you'll definitely run into differences between what's supported by default.

自然,除了功能集之间的差异外,内置了Mac OS X上不同的bash版本的内置程序,您还将在其他工具中发现差异.例如,Mac OS X上存在getopt问题(自变量不支持在Mac OS X目录/文件路径中经常出现的空格;新版bash中的内置getopts可以提供帮助与此相关,但可能在较早的版本中不可用).当然,还会有其他具有不同功能或语法的工具.

Naturally, beyond the differences between feature sets & built-ins for the different bash versions on Mac OS X , you'll also find differences in other tools. For example, there are getopt issues on Mac OS X (spaces, which are frequently found in Mac OS X directory/file paths, are not supported in arguments; the built-in getopts in newer bash versions can help with this, but may not be available in older versions). Naturally, there will be other tools that have different functionalities or syntaxes as well.

我绝对不是专家bash开发人员,但是我编写了 number 特定于Mac OS X的脚本,这些脚本支持各种发行版.请参阅我的 Bash和替代项中的正则表达式文章以进行讨论2.x与3.x正则表达式的功能和变通办法.或者,我的某些bash脚本已将Mac OS X纳入考虑范围: tools-osx & bash_stub .

I'm definitely not an expert bash developer, but I've written a number of Mac OS X-specific scripts that support various releases. See my Regular Expressions in Bash and Alternatives article for discussion of the 2.x vs 3.x regular expression features and workarounds. Or, some of my bash scripts which have taken Mac OS X into heavy consideration: tools-osx & bash_stub.

这篇关于达尔文/MacOS会修改Bash吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆