Description: Allow setting the version via ldflags Upstream commit 1409e2c (cmd/shfmt: drop support for setting the version via ldflags) dropped support for setting the version via ldflags. The version is now stamped in the binary by go-build(1) based on the tag and/or the commit hash. Since this upstream change breaks `shfmt --version`, let's revert the aforementioned commit. Author: Vincent Blut Forwarded: no Last-Update: 2026-05-14 --- This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ --- a/cmd/shfmt/main.go +++ b/cmd/shfmt/main.go @@ -105,6 +105,8 @@ color bool copyBuf = make([]byte, 32*1024) + + version = "(devel)" ) func main() { @@ -156,8 +158,7 @@ flag.Parse() if versionFlag.val { - version := "(unknown)" - if info, ok := debug.ReadBuildInfo(); ok { + if info, ok := debug.ReadBuildInfo(); ok && version == "(devel)" { mod := &info.Main if mod.Replace != nil { mod = mod.Replace