shellsplit ready
POSIX sh word splitting honouring single quotes, double quotes and backslash escapes, exactly as Ruby’s Shellwords.shellsplit does.
CGO_ENABLED=0LICENSE=BSD-3-ClauseTested onamd64arm64riscv64loong64ppc64les390xRuby's Shellwords split, escape & join in Go — MRI-compatible, .
$ go get github.com/go-ruby-shellwords/shellwords@latest
go-ruby-shellwords is a pure-Go (no cgo) reimplementation of Ruby's Shellwords library — shellsplit, shellescape and shelljoin that match reference Ruby's behaviour byte-for-byte. It performs POSIX sh word splitting honouring single quotes, double quotes and backslash escapes, escapes a string so it survives one round of shell parsing, and joins an array of words back into a shell-safe command line — the inverse of splitting, with shellsplit(shelljoin(words)) == words guaranteed. An unmatched quote raises the same ArgumentError at the same point. It was extracted from rbgo's prelude/internals into a reusable standalone library: no dependency on the Ruby runtime, the dependency runs the other way. It is the Shellwords backend for go-embedded-ruby, bound by rbgo as a native module just like go-ruby-regexp and go-ruby-erb — differential-tested against MRI, 100% coverage, CI green across 6 arches and 3 OSes.
POSIX sh word splitting honouring single quotes, double quotes and backslash escapes, exactly as Ruby’s Shellwords.shellsplit does.
Escaping a single string so it survives one round of shell parsing, byte-for-byte identical to MRI (including the empty-string '' case).
Joining an array of words into a single shell-safe command line, the inverse of shellsplit, matching reference Ruby.
An unmatched quote raises the same ArgumentError Ruby raises, at the same point in the input.
shellsplit(shelljoin(words)) == words over arbitrary words, the property reference Ruby guarantees.
A wide word corpus split, escaped and joined both here and by the system ruby/shellwords, compared byte-for-byte; 100% coverage, gofmt + go vet clean, green across all six 64-bit Go arches and three OSes.
A faithful port of Ruby's Shellwords in pure Go, cgo disabled, so it cross-compiles and embeds anywhere. It splits, escapes and joins shell words the way reference Ruby does — POSIX sh quoting and backslash escapes, the empty-string '' case, the ArgumentError on an unmatched quote, and the shellsplit(shelljoin(words)) == words round-trip property. Validated differentially against the system ruby binary — split, escaped and joined output compared against shellwords. It is a standalone, reusable module extracted from rbgo's internals, and the Shellwords backend for the sibling org github.com/go-embedded-ruby.