Skip to content

release.yml still uses GNU-only \s in sed - portability leftover from #2 #7

Description

TLDR

release.yml still uses the GNU-only \s in a sed -E expression. It works where it runs (ubuntu), so this is not a live bug - but it is the same portability issue #2 fixed, left behind in one file, and it makes the release check impossible to reproduce locally on macOS.

The leftover

.github/workflows/release.yml:19:

TOML_VERSION="$(grep '^version' distro.toml | sed -E 's/^[^=]+=\s*"([^"]+)".*/\1/')"

PR #2 ("fix: use POSIX character class in sed for macOS compatibility") changed exactly this pattern in install.sh, converting \s to the POSIX class [[:space:]]. It touched only install.sh - 2 lines, 1 file - so the identical expression in release.yml was never updated.

The repo now speaks two dialects of the same one-line expression:

Location Expression
install.sh:35 sed -E 's/^[^=]+=[[:space:]]*"([^"]+)".*/\1/'
install.sh:125 sed -E 's/^[^=]+=[[:space:]]*"?([^"#]+)"?.*/\1/'
release.yml:19 sed -E 's/^[^=]+=\s*"([^"]+)".*/\1/'

Why it is not urgent

That line only ever executes on ubuntu-latest, where GNU sed handles \s correctly. Releases v0.9.2 through v0.11.0 all passed the version check cleanly. Nothing is broken in CI, and nothing needs an urgent fix.

Why it is still worth fixing

BSD sed does not support \s. It does not error - it silently fails to substitute and passes the whole line through:

$ grep '^version' distro.toml | sed -E 's/^[^=]+=\s*"([^"]+)".*/\1/'     # BSD / macOS
version = "0.11.0"      # bump on meaningful config changes; major = breaking (requires reinstall)

$ grep '^version' distro.toml | perl -pe 's/^[^=]+=\s*"([^"]+)".*/$1/'   # GNU equivalent
0.11.0

So anyone reproducing the release gate locally on a Mac - reasonable, given the workflow is the thing that can block a release - gets a bogus MISMATCH and has to work out that their sed is at fault rather than their release. This was hit for real while cutting v0.11.0.

Fixing it also means the next person grepping for this expression finds one form, not two.

Proposed change

Match install.sh and use the POSIX character class:

TOML_VERSION="$(grep '^version' distro.toml | sed -E 's/^[^=]+=[[:space:]]*"([^"]+)".*/\1/')"

[[:space:]] is POSIX and works identically under GNU sed, so CI behaviour is unchanged.

Verification note

This line lives in the release gate, and the gate only truly runs on a tag push. The change will be verified by executing the exact expression against the real distro.toml under both sed dialects and asserting both yield 0.11.0, rather than by cutting a throwaway release.

Reversibility

Two-way door - single expression, no behaviour change on the platform that runs it, trivially revertible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions