translated

This commit is contained in:
geekpi 2019-01-25 08:58:31 +08:00
parent d8525aa462
commit 1b6a043877
2 changed files with 80 additions and 80 deletions

View File

@ -1,80 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Bash 5.0 Released with New Features)
[#]: via: (https://itsfoss.com/bash-5-release)
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
Bash 5.0 Released with New Features
======
The [mailing list][1] confirmed the release of Bash-5.0 recently. And, it is exciting to know that it comes baked with new features and variable.
Well, if youve been using Bash 4.4.XX, you will definitely love the fifth major release of [Bash][2].
The fifth release focuses on new shell variables and a lot of major bug fixes with an overhaul. It also introduces a couple of new features along with some incompatible changes between bash-4.4 and bash-5.0.
![Bash logo][3]
### What about the new features?
The mailing list explains the bug fixed in this new release:
> This release fixes several outstanding bugs in bash-4.4 and introduces several new features. The most significant bug fixes are an overhaul of how nameref variables resolve and a number of potential out-of-bounds memory errors discovered via fuzzing. There are a number of changes to the expansion of $@ and $* in various contexts where word splitting is not performed to conform to a Posix standard interpretation, and additional changes to resolve corner cases for Posix conformance.
It also introduces some new features. As per the release note, these are the most notable new features are several new shell variables:
> The BASH_ARGV0, EPOCHSECONDS, and EPOCHREALTIME. The history builtin can remove ranges of history entries and understands negative arguments as offsets from the end of the history list. There is an option to allow local variables to inherit the value of a variable with the same name at a preceding scope. There is a new shell option that, when enabled, causes the shell to attempt to expand associative array subscripts only once (this is an issue when they are used in arithmetic expressions). The globasciiranges shell option is now enabled by default; it can be set to off by default at configuration time.
### What about the changes between Bash-4.4 and Bash-5.0?
The update log mentioned about the incompatible changes and the supported readline version history. Heres what it said:
> There are a few incompatible changes between bash-4.4 and bash-5.0. The changes to how nameref variables are resolved means that some uses of namerefs will behave differently, though I have tried to minimize the compatibility issues. By default, the shell only sets BASH_ARGC and BASH_ARGV at startup if extended debugging mode is enabled; it was an oversight that it was set unconditionally and caused performance issues when scripts were passed large numbers of arguments.
>
> Bash can be linked against an already-installed Readline library rather than the private version in lib/readline if desired. Only readline-8.0 and later versions are able to provide all of the symbols that bash-5.0 requires; earlier versions of the Readline library will not work correctly.
I believe some of the features/variables added are very useful. Some of my favorites are:
* There is a new (disabled by default, undocumented) shell option to enable and disable sending history to syslog at runtime.
* The shell doesnt automatically set BASH_ARGC and BASH_ARGV at startup unless its in debugging mode, as the documentation has always said, but will dynamically create them if a script references them at the top level without having enabled debugging mode.
* The history can now delete ranges of history entries using -d start-end.
* If a non-interactive shell with job control enabled detects that a foreground job died due to SIGINT, it acts as if it received the SIGINT.
* BASH_ARGV0: a new variable that expands to $0 and sets $0 on assignment.
To check the complete list of changes and features you should refer to the [Mailing list post][1].
### Wrapping Up
You can check your current Bash version, using this command:
```
bash --version
```
Its more likely that youll have Bash 4.4 installed. If you want to get the new version, I would advise waiting for your distribution to provide it.
With Bash-5.0 available, what do you think about it? Are you using any alternative to bash? If so, would this update change your mind?
Let us know your thoughts in the comments below.
--------------------------------------------------------------------------------
via: https://itsfoss.com/bash-5-release
作者:[Ankush Das][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/ankush/
[b]: https://github.com/lujun9972
[1]: https://lists.gnu.org/archive/html/bug-bash/2019-01/msg00063.html
[2]: https://www.gnu.org/software/bash/
[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/01/bash-logo.jpg?resize=800%2C450&ssl=1

View File

@ -0,0 +1,80 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Bash 5.0 Released with New Features)
[#]: via: (https://itsfoss.com/bash-5-release)
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
Bash 5.0 发布了新功能
======
[邮件列表][1]证实最近发布了 Bash-5.0。而且,令人兴奋的是它还有新功能和新变量。
如果你一直在使用 Bash 4.4.XX那么你一定会喜欢 [Bash][2] 的第五个主要版本。
第五个版本侧重于新的 shell 变量和许多重大漏洞修复。它还引入了一些新功能还有一些让 bash-4.4 和 bash-5.0 之间不兼容的更改。
![Bash logo][3]
### 新功能怎么样?
邮件列表解释了此版本中修复的 bug
> 此版本修复了 bash-4.4 中的几个主要错误,并引入了几个新功能。最重要的 bug 修复是对 nameref 变量的解析以及通过模糊测试发现的许多潜在的内存越界错误。在为了符合 Posix 标准解释而不进行单词拆分的上下文中,对 $@ 和 $* 的展开做了许多变化,另外还有解决极端情况中 Posix 一致性的修改。
它还引入了一些新功能。根据发布说明,最值得注意的新功能是几个新的 shell 变量:
> BASH_ARGV0、EPOCHSECONDS 和 EPOCHREALTIME。内置的 “history” 可以删除指定范围的条目并能将负数理解为从历史末端开始的偏移量。有一个选项允许局部变量继承前一个范围内具有相同名称的变量的值。有一个新的shell选项在启用它时会导致 shell 只尝试一次扩展关联数组下标这在算术表达式中使用时会出现问题。“globasciiranges” 这个 shell 选项现在默认启用。可以在配置时默认关闭它。
### Bash-4.4 和 Bash-5.0 之间有哪些变化?
更新日志提到了不兼容的更改和支持 readline 版本历史记录。它是这么说的:
> bash-4.4 和 bash-5.0 之间存在一些不兼容的变化。尽管我已经尽量最小化兼容性问题,但是对 nameref 变量解析的更改意味着对 namerefs 的某些使用会有不同的行为。默认情况下如果启用了扩展调试模式shell 仅在启动时设置 BASH_ARGC 和 BASH_ARGV。它被无条件地设置是一个疏忽并且在脚本传递大量参数时会导致性能问题。
>
>如果需要,可以将 Bash 链接到已安装的 Readline 库,而不是 lib/readline 中的私有版本。只有 readline-8.0 及更高版本能够提供 bash-5.0 所需的所有符号。早期版本的 Readline 库无法正常工作。
我相信一些添加的功能/变量非常有用。我最喜欢的一些是:
* 有一个新的默认情况下禁用文档中没有说明shell 选项,用于在运行时启用/禁用向 syslog 发送历史记录。
* 正如文档一直所说的那样,除非 shell 处于调试模式,否则它不会在启动时自动设置 BASH_ARGC 和 BASH_ARGV但如果脚本在上层引用它们且没有启用调试模式那么 shell 将动态创建它们。
* 现在可以使用 “-d start-end” 删除指定范围的 “history” 条目。
* 如果启用了作业控制的非交互式 shell 检测到前台作业因 SIGINT 而死亡,则其行为就像接收到 SIGINT 一样。
* BASH_ARGV0一个新变量扩展为 $0 并在赋值时设置 $0。
要查看完整的更改和功能列表,请参阅[邮件列表文章][1]。
### 总结
你可以使用下面的命令检查你当前的 Bash 版本:
```
bash --version
```
你很可能安装了 Bash 4.4。如果你想获得新版本,我建议等待你的发行版提供它。
你怎么看待 Bash-5.0 发布?你在使用其他 bash 的替代品么?如果有的话,这个更新会改变你的想法么?
请在下面的评论中告诉我们你的想法。
--------------------------------------------------------------------------------
via: https://itsfoss.com/bash-5-release
作者:[Ankush Das][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/ankush/
[b]: https://github.com/lujun9972
[1]: https://lists.gnu.org/archive/html/bug-bash/2019-01/msg00063.html
[2]: https://www.gnu.org/software/bash/
[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/01/bash-logo.jpg?resize=800%2C450&ssl=1