DEV Community

Qiang Li
Qiang Li

Posted on Originally published at github.com

bashy: a pure-Go Bash 5.3 that runs on Windows and rebuilds itself from the downloaded binary

I've been building a Bash 5.3 in pure Go — no CGo, one static binary — on top of mvdan/sh, mostly so the same scripts run on Windows. It passes all 86 runnable fixtures of GNU Bash's own test suite on Linux and macOS. (The Windows run is not yet measured to the same standard — an honest gap; the README lists what is still known-different.)

Install

A tarball on Linux/macOS, a zip on Windows: https://github.com/qiangli/bashy/releases/latest

There is a small tour repo with 27 scripts and their pinned transcripts you can diff on your own machine: https://github.com/qiangli/bashsharp-tour

The part I'd most like poked at

On Windows it needs nothing else. bashy git clone fetches a pinned MinGit, bashy dag build provisions its own Go toolchain, and the binary rebuilds itself. This is a stock box with no git, no Go and no C compiler:

bashy rebuilding itself on Windows

curl.exe -fsSLO https://github.com/qiangli/bashy/releases/latest/download/bashy-windows-amd64.zip
tar.exe -xf bashy-windows-amd64.zip
.\bashy git clone https://github.com/qiangli/bashy
cd bashy; ..\bashy scripts/bootstrap-siblings.sh; ..\bashy dag build
bin\bashy.exe --version
Enter fullscreen mode Exit fullscreen mode

Where it probably breaks

Odd set -o combinations, traps, and coproc — that is where the last bugs live. Every "it broke here" gets an issue link back: https://github.com/qiangli/bashy/issues

It also has an opt-in superset dialect behind a flag; with the flag off you get plain bash, and that's all this post is about.

BSD-3. The engine is mvdan/sh by Daniel Martí, forked and credited.

Top comments (0)