AMAZINGINDEX.COM 日报快照
56.4
VOL. 2026.05
2026.05.24
← 返回 2026.05.24 日报
日报快照 · Daily Snapshot
NO. 013

Ruby 重写 Bash 兼容 Shell

#ARTICLE HackerNews 2026.05.24
推荐指数 46.0 NO. 013 · 2026.05.24
发布2026/05/23Score146Comments87

Rubish 将 Bash 语法解析编译为 Ruby 代码在 Ruby VM 执行,实现完全 Bash 兼容的同时允许在 Shell 中无缝嵌入 Ruby 代码。对 Ruby 生态开发者来说,这意味着无需在 Bash 和 Ruby 之间切换语境,可以用统一语言完成运维脚本到业务逻辑的全栈工作。

运维和 DevOps 场景中,团队通常用 Bash 写胶水脚本、用 Ruby 写业务逻辑,两套语法和数据结构频繁转换是长期痛点。Rubish 的思路与 Oil shell(用 Python 语法兼容 Bash)类似,但绑定 Ruby 生态更紧密,可以直接操作 Rails 对象和 Gem 库。

不过性能是隐忧:Shell 脚本常涉及大量管道和 fork,Ruby VM 的启动延迟和 GIL 可能让高频命令场景变慢。如果你团队在重度使用 Ruby(如 Rails 基础设施、Chef/Puppet 遗留系统),这个工具值得作为渐进替换的试点;纯性能敏感场景建议先跑 benchmark 对比原生 Bash。

正面 74 条评论

核心争论:Ruby 性能争议:脚本语言速度是否重要,以及管道语法与方法链的偏好之争

minraws

Is it just me of did others also read rubbish instead of rubi-sh...I think that might be the joke. hm...

pelasaco

The repository owner is a true ruby hero. I am not sure if the name is a joke, and he was just fooling around, but the code is real.

s_trumpet

For a while the preferred templating engine for .erb files was “erubis” which is the Japanese pronunciation for Elvis

替代方案: BashGoPythonPerlCJavaScriptRusterubis
查看原文 →