Tech

Ruby Developer Releases Rubish, a Bash-Compatible Unix Shell

Developer amatsuda publishes Rubish, a pure Ruby shell that compiles syntax to the Ruby VM while maintaining full Bash compatibility.

Author
Owen Mercer
Markets and Finance Editor
Published
Draft
Source: Hacker News · original
Tech
No image available
New GitHub repository allows deep integration of Ruby code within shell commands

Developer amatsuda has published Rubish, a new Unix shell implementation written entirely in Ruby. The project, now available on GitHub, parses shell syntax and compiles it into Ruby code for execution by the Ruby virtual machine. The tool claims full compatibility with Bash, allowing existing Bash scripts to run without modification.

Rubish distinguishes itself by deeply integrating Ruby features into the shell environment. Users can mix shell commands with Ruby code, utilising blocks, iterators, and libraries directly within scripts. Ruby expressions can serve as conditions in if, while, and until statements when wrapped in curly braces, with shell variables automatically bound as local variables within those expressions.

The shell supports command invocation via Ruby method call syntax with parentheses, in addition to traditional UNIX style. Commands can be chained with Ruby methods using dot notation to form pipelines. Ruby iterator methods such as .each, .map, .select, and .detect can process command output line by line using blocks. Any line starting with a capital letter is evaluated directly as Ruby code, enabling immediate access to Ruby classes and methods from the prompt.

To manage performance, Rubish includes lazy loading for shell initialisation. Slow setup code, such as rbenv or nvm initialisation, can be deferred to a background thread to keep startup instant. The tool also exposes a public API for in-process integration with other Ruby programs, allowing terminal emulators or IDE plugins to drive a Rubish session without forking or using JSON serialization.

Security considerations are addressed through a safe mode activated by running rubish -r. This disables all Ruby integration features, including inline evaluation and lambdas, restricting execution to standard shell syntax for untrusted scripts. The repository welcomes bug reports and pull requests, noting that any Bash script failing to run in Rubish is considered a bug.

Continue reading

More from Tech

Read next: Quantum ‘Jamming’ Tests the Limits of Cryptographic Security and Causality
Read next: WIRED Reviewer Endorses L.L.Bean Zip Hunter’s Tote for Rugged Utility
Read next: Google’s Gemini Omni Flash delivers mixed results in hands-on testing