Skip to content

hack/register_version.sh depends on GNU sed and misbehaves on macOS #731

Description

hack/register_version.sh only works with GNU sed. On macOS with the stock BSD sed, it fails on one path and silently edits the wrong lines on the other.

Registering a new version inserts the block with the one-line form of a\, which is a GNU extension. BSD sed stops with:

sed: 1: "/^  versions:$/a\    -  ...": extra characters after \ at the end of a command

I hit it by running hack/release_next.sh --release-tag v9.9.0 in a scratch copy with /usr/bin/sed first in PATH. The same run with GNU sed passes.

Re-registering an existing version is worse. The range end /^ - version:\|^ [^ ]/ uses \|, and BSD sed does not read that as alternation in a basic regex, so the end never matches and the range runs to the end of hugo.yaml. Every hidden: true and label: line after the target version gets deleted, with no error. A quick check:

printf 'a\n    - version: x\nb\n  c: 1\n' | /usr/bin/sed -n '/^    - version:\|^  [^ ]/p'   # prints nothing
printf 'a\n    - version: x\nb\n  c: 1\n' | gsed -n '/^    - version:\|^  [^ ]/p'       # prints both lines

The release workflow runs on Linux, so CI never sees this. Only a local make release-next on a Mac does. The self-check added in #710 works around it by putting gsed in front of sed.

The script already reads hugo.yaml with yq, so the simplest fix is to do both edits with yq too. The other option is to check for GNU sed at the top and exit with a clear message when it is missing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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