mvdan / sh

A shell parser, formatter, and interpreter with bash support; includes shfmt
https://pkg.go.dev/mvdan.cc/sh/v3
BSD 3-Clause "New" or "Revised" License
6.97k stars 332 forks source link

Allow building with Tinygo #1078

Open diamondburned opened 1 month ago

diamondburned commented 1 month ago

This PR contains commits that allow mvdan.cc/sh/v3 to be built using Tinygo. The commit messages will contain more information.

mvdan commented 1 month ago

Thanks, I'm fine with supporting tinygo builds and adding it to CI.

I'm not super pumped about adding tinygo build tags, though. Ideally, tags like cgo or purego would be enough for the code on master to already be portable. For example, with either CGO_ENABLED=0 or -tags=purego, os/user.Lookup on Linux should be a stub that returns nothing, why is that not enough for Tinygo?

https://tinygo.org/docs/reference/lang-support/stdlib/#osuser does show a failure, but that seems like a bug that should be tracked/fixed upstream.

diamondburned commented 1 month ago

https://tinygo.org/docs/reference/lang-support/stdlib/#osuser does show a failure, but that seems like a bug that should be tracked/fixed upstream.

I made https://github.com/tinygo-org/tinygo/pull/4278 to address this.