@@ -60,29 +60,30 @@ clean: ## Clean build artifacts
6060 find . -type f -name " *.pyc" -delete 2> /dev/null || true
6161
6262# Trailing whitespace targets
63- # Note: fix-trailing-whitespace requires GNU sed (gsed) on macOS
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. Install with : brew install gnu-sed)
68+ endif
69+ else
70+ SED := sed
71+ endif
72+
6473.PHONY : fix-trailing-whitespace
6574fix-trailing-whitespace : # # Remove trailing whitespaces from all files
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 \( \
75+ @echo " Removing trailing whitespaces from all files..."
76+ @find . -type f \( \
7877 -name " *.py" -o -name " *.toml" -o -name " *.md" -o -name " *.yaml" \
7978 -o -name " *.yml" -o -name " *.json" \) \
8079 -not -path " ./.git/*" \
8180 -not -path " ./.mypy_cache/*" \
8281 -not -path " ./.pytest_cache/*" \
8382 -not -path " ./.ruff_cache/*" \
84- -exec sh -c " $$ SED -i -e 's/[[:space:]]*$$ //' \"\$ $1 \" " _ {} \; && \
85- echo " Trailing whitespaces removed."
83+ -exec sh -c \
84+ ' $(SED) -i -e "s/[[:space:]]*$$//" "$$1"' \
85+ _ {} \; && \
86+ echo " Trailing whitespaces removed."
8687
8788.PHONY : check-trailing-whitespace
8889check-trailing-whitespace : # # Check for trailing whitespaces in source files
0 commit comments