gitmyhub

fsh

C ★ 59 updated 1mo ago

FreeBSD shell port for use on MacOS

A port of FreeBSD's sh shell to macOS, useful for scripts that need predictable echo behavior that zsh does not provide.

ClibeditmacOSsetup: moderatecomplexity 2/5

This project ports FreeBSD's sh shell to macOS, giving Mac users access to a Bourne-lineage shell that behaves differently from the zsh shell Apple ships by default. The main reason someone would reach for it is a specific difference in how the two shells handle the echo command.

On macOS, zsh's built-in echo interprets escape characters like \n (newline) and \t (tab) automatically. That means typing echo "hello\nworld" in zsh actually prints two lines. FreeBSD sh does not do this. Its echo prints exactly what you give it, and escape interpretation only happens if you explicitly ask for it with a flag. This matters for scripts that need to produce consistent, predictable output across different systems and shells.

The project takes the shell source from a February 2023 snapshot of the FreeBSD codebase and adds a small compatibility layer to make it compile on macOS. It links against libedit, a library that provides line editing, command history, and tab completion in the terminal. The resulting binary is called fsh and installs to ~/bin by default.

Building it requires Xcode Command Line Tools and Homebrew, which are standard tools for developers on Mac. The README includes a short demonstration showing the difference in echo behavior between fsh and zsh side by side. The license is BSD-2-Clause, the same permissive license FreeBSD itself uses.

The README is short and focused. It covers the motivation, build steps, a quick test, and the source origin. There is no package installer available yet (the Homebrew tap section is commented out in the source), so building from source is the only install path at the moment.

Where it fits