@@ -60,31 +60,29 @@ clean: ## Clean build artifacts
6060 find . -type f -name " *.pyc" -delete 2> /dev/null || true
6161
6262# Trailing whitespace targets
63- UNAME_S := $(shell uname -s)
64- ifeq ($(UNAME_S ) ,Darwin)
65- SED := $(shell command -v gsed 2>/dev/null)
66- ifeq ($(SED),)
67- $(error GNU sed (gsed) not found on macOS. \
68- Install with: brew install gnu-sed)
69- endif
70- else
71- SED := sed
72- endif
73-
63+ # Note: fix-trailing-whitespace requires GNU sed (gsed) on macOS
7464.PHONY : fix-trailing-whitespace
7565fix-trailing-whitespace : # # Remove trailing whitespaces from all files
76- @echo " Removing trailing whitespaces from all files..."
77- @find . -type f \( \
66+ @if [ " $$ (uname -s)" = " Darwin" ]; then \
67+ SED=$$(command -v gsed 2>/dev/null ) ; \
68+ if [ -z " $$ SED" ]; then \
69+ echo " Error: GNU sed (gsed) not found on macOS." ; \
70+ echo " Install with: brew install gnu-sed" ; \
71+ exit 1; \
72+ fi ; \
73+ else \
74+ SED=sed; \
75+ fi ; \
76+ echo " Removing trailing whitespaces from all files..." ; \
77+ find . -type f \( \
7878 -name " *.py" -o -name " *.toml" -o -name " *.md" -o -name " *.yaml" \
7979 -o -name " *.yml" -o -name " *.json" \) \
8080 -not -path " ./.git/*" \
8181 -not -path " ./.mypy_cache/*" \
8282 -not -path " ./.pytest_cache/*" \
8383 -not -path " ./.ruff_cache/*" \
84- -exec sh -c \
85- ' $(SED) -i -e "s/[[:space:]]*$$//" "$$1"' \
86- _ {} \; && \
87- echo " Trailing whitespaces removed."
84+ -exec sh -c " $$ SED -i -e 's/[[:space:]]*$$ //' \"\$ $1 \" " _ {} \; && \
85+ echo " Trailing whitespaces removed."
8886
8987.PHONY : check-trailing-whitespace
9088check-trailing-whitespace : # # Check for trailing whitespaces in source files
0 commit comments