From f5249a58efe941e53e9e7390d51caa31cba6afab Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Tue, 20 Oct 2026 08:58:08 +0200 Subject: [PATCH] common.mk: Set WHICH to command -v defs.mk derives WHICH from the external which binary, first from a hardcoded /usr/bin/which path and then with a `which which` fallback, while the probes for time, ruff, pyright, and python3 call which directly. Systems that do not ship the which package, such as minimal containers, are left to the shell's PATH search. Define WHICH once in common.mk as the POSIX command -v builtin and drop the old definition from defs.mk. Route the remaining direct which calls through $(WHICH): - projects-dir.mk: TIME probe - py-check.mk: PY_CHECK_RUFF and PY_CHECK_PYRIGHT probes - py-version.mk: PYTHON lookup command -v runs in the /bin/sh that $(shell) already uses, so the build no longer depends on the which package. The builtin names that command -v reports for echo, test, pwd, and printf are safe, because every use of those variables runs through the shell, and the bash time keyword keeps the -p output format identical to the GNU time binary. Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.3.0 Signed-off-by: Jan Lindemann --- make/common.mk | 3 +++ make/defs.mk | 3 --- make/projects-dir.mk | 2 +- make/py-check.mk | 4 ++-- make/py-version.mk | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/make/common.mk b/make/common.mk index 7cfb509e..4ad785b3 100644 --- a/make/common.mk +++ b/make/common.mk @@ -7,6 +7,9 @@ COMMON_MK_INCLUDED = true Q ?= @ INTERACTIVE ?= auto +ifndef WHICH + WHICH := command -v +endif BROWSER ?= xdg-open JWB_SCRIPT_DIR ?= $(firstword $(wildcard $(JWBDIR)/scripts $(JWBDIR)/bin) jwb-script-dir-not-found) diff --git a/make/defs.mk b/make/defs.mk index 78f856ca..277fc2de 100644 --- a/make/defs.mk +++ b/make/defs.mk @@ -11,9 +11,6 @@ include $(JWBDIR)/make/projects.mk # ----- Executables -ifndef WHICH - WHICH := $(firstword $(wildcard /usr/bin/which) $(shell which which)) -endif ifndef GREP GREP := $(shell $(WHICH) grep) endif diff --git a/make/projects-dir.mk b/make/projects-dir.mk index 09b60335..9d8a5f50 100644 --- a/make/projects-dir.mk +++ b/make/projects-dir.mk @@ -115,7 +115,7 @@ endif EDITOR ?= xdg-open ifeq ($(TIME),) - TIME := $(shell which time) + TIME := $(shell $(WHICH) time) ifneq ($(TIME),) TIME += -p endif diff --git a/make/py-check.mk b/make/py-check.mk index 35e5fc30..4970e792 100644 --- a/make/py-check.mk +++ b/make/py-check.mk @@ -23,7 +23,7 @@ ifndef PY_CHECK_MYPY endif ifndef PY_CHECK_RUFF - PY_CHECK_RUFF := $(shell which ruff 2>/dev/null) + PY_CHECK_RUFF := $(shell $(WHICH) ruff 2>/dev/null) ifneq ($(PY_CHECK_RUFF),) PY_CHECK_RUFF += --config $(TOPDIR)/pyproject.toml endif @@ -38,7 +38,7 @@ ifndef PY_CHECK_YAPF endif ifndef PY_CHECK_PYRIGHT - PY_CHECK_PYRIGHT := $(shell which pyright 2>/dev/null) + PY_CHECK_PYRIGHT := $(shell $(WHICH) pyright 2>/dev/null) TD_GENERATE_FILES += pyrightconfig.json endif diff --git a/make/py-version.mk b/make/py-version.mk index c705891a..3e4ec0dc 100644 --- a/make/py-version.mk +++ b/make/py-version.mk @@ -6,7 +6,7 @@ ifneq ($(PYTHON_VERSION),) else ifeq ($(PYTHON),) #PYTHON := $(lastword $(shell /bin/bash -O extglob -c "ls -v /usr/bin/python[0-9].+([0-9])")) - PYTHON := $(shell which python3 | xargs readlink -f) + PYTHON := $(shell $(WHICH) python3 | xargs readlink -f) endif PYTHON_VERSION ?= $(patsubst python%,%,$(notdir $(PYTHON))) endif -- 2.56.0