Brush v0.4.0

Brush v0.4.0

Brush is a command shell written in Rust that combines POSIX and Bash compatibility with memory safety guarantees and performance. The project aims to become a full-fledged alternative to traditional shells, allowing existing scripts to be run and .bashrc to be used virtually unchanged. This version represents several months of work and over 200 merged pull requests, significantly moving the shell toward becoming a full-fledged replacement for Bash and POSIX-compliant environments.

Key development areas in this issue:

  • Bash compatibility: added set -e, set -u, pipefail, failglob, ERR handler, coprocesses and much more;
  • reliability: improved handling of exceptional cases – closed channels, broken output, non-UTF8 history, and others;
  • Platforms: Expanded support for macOS (working as a login shell), improved performance on Windows, FreeBSD, Android, and 32-bit systems;
  • Interactivity: added optional TOML configs, preexec/precmd hooks, improved readline macro support, and more.

Key Bash Compatibility Improvements

The most important improvements in this release were the significant expansion of Bash feature support. Error management:

  • set -e (errexit) – exit immediately on error;
  • set -u (nounset) – error when accessing an undeclared variable;
  • pipefail – the return code of the pipeline is determined by the last failed command;
  • failglob – Failure to find a match for a glob expression now results in an error.

Handlers (Traps) and coprocesses:

  • ERR handler - allows you to execute commands when an error occurs;
  • coprocesses (coproc) - launching background processes with two-way communication.

Built-in commands:

  • Improved handling of many arithmetic constructs, including high-radix literals, overflow, and assignment operators;
  • Fixes and improvements affected built-in commands: caller, read, getopts, printf and others.

Expanding platform support:

Release v0.4.0 makes the shell available on a wider range of devices:

  • macOS: Fixed an issue where the shell would freeze when logging in. Brush can now be used as a login shell.
  • Windows: Improvements to path handling, added /dev/null emulation, which significantly improves usability on Windows;
  • FreeBSD and Android: building for these platforms is supported;

Interactive Features and APIs

  • Configuration: Added support for an optional TOML config file (~/.config/brush/config.toml) for brush-specific settings;
  • Customization: Implemented zsh-style preexec/precmd hooks (behind the experimental flag), useful for creating custom prompts and timing tools;
  • API for developers: The Shell type is now parameterized by extensions (ShellExtensions), allowing developers to add their own built-in commands and change the behavior of variables without having to fork the project;
  • Miscellanea:
    • Improved readline macro support for compatibility with starship, atuin и fzf (github.com);
    • Added AST and shell state serialization capabilities via serde;
    • serde functions are now available in brush-parser and brush-core to allow serialization of AST and shell state.

Source: linux.org.ru

Add a comment