From ac94316d9e175e567a3e21d099482c389e2426f9 Mon Sep 17 00:00:00 2001 From: Nathan Drew <1035229+NaffanDroo@users.noreply.github.com> Date: Wed, 1 Jul 2026 19:43:33 +0100 Subject: [PATCH] fix: make reset-version portable across BSD and GNU sed sed -i -E on macOS was broken because BSD sed's -i requires an explicit backup-suffix argument, so it consumed -E as that suffix instead of enabling extended regex. This left capture groups undefined, causing "\1 not defined in the RE". Detect the OS via uname and pick the correct in-place sed invocation, and drop a stray space in the replacement that produced version = " 0.0.1". --- Makefile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0cf61e6..2532fff 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,11 @@ .PHONY: deps pre-commit test reset-version +UNAME_S := $(shell uname -s) +ifeq ($(UNAME_S),Darwin) + SED_INPLACE := sed -i '' +else + SED_INPLACE := sed -i +endif deps: @echo "=== Install dependencies ===" @@ -18,7 +24,7 @@ test: deps pre-commit reset-version: @echo "=== Resetting version numbers to 0.0.1 ===" # Only update the version field in pyproject.toml - sed -i -E 's/^(version = ")([0-9]+\.[0-9]+\.[0-9]+)(")/\1 0.0.1\3/' pyproject.toml + $(SED_INPLACE) -E 's/^(version = ")([0-9]+\.[0-9]+\.[0-9]+)(")/\10.0.1\3/' pyproject.toml # Update version numbers in .py files - find . -type f -name '*.py' -exec sed -i -E 's/[0-9]+\.[0-9]+\.[0-9]+/0.0.1/g' {} + + find . -type f -name '*.py' -exec $(SED_INPLACE) -E 's/[0-9]+\.[0-9]+\.[0-9]+/0.0.1/g' {} + @echo "--- Version numbers reset to 0.0.1 ---"