common.mk: Set WHICH to command -v
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 5m32s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 5m49s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 5m13s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 5m28s
CI / Packaging test (push) Successful in 0s

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 <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-10-20 08:58:08 +02:00
commit f5249a58ef
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61
5 changed files with 7 additions and 7 deletions

View file

@ -7,6 +7,9 @@ COMMON_MK_INCLUDED = true
Q ?= @ Q ?= @
INTERACTIVE ?= auto INTERACTIVE ?= auto
ifndef WHICH
WHICH := command -v
endif
BROWSER ?= xdg-open BROWSER ?= xdg-open
JWB_SCRIPT_DIR ?= $(firstword $(wildcard $(JWBDIR)/scripts $(JWBDIR)/bin) jwb-script-dir-not-found) JWB_SCRIPT_DIR ?= $(firstword $(wildcard $(JWBDIR)/scripts $(JWBDIR)/bin) jwb-script-dir-not-found)

View file

@ -11,9 +11,6 @@ include $(JWBDIR)/make/projects.mk
# ----- Executables # ----- Executables
ifndef WHICH
WHICH := $(firstword $(wildcard /usr/bin/which) $(shell which which))
endif
ifndef GREP ifndef GREP
GREP := $(shell $(WHICH) grep) GREP := $(shell $(WHICH) grep)
endif endif

View file

@ -115,7 +115,7 @@ endif
EDITOR ?= xdg-open EDITOR ?= xdg-open
ifeq ($(TIME),) ifeq ($(TIME),)
TIME := $(shell which time) TIME := $(shell $(WHICH) time)
ifneq ($(TIME),) ifneq ($(TIME),)
TIME += -p TIME += -p
endif endif

View file

@ -23,7 +23,7 @@ ifndef PY_CHECK_MYPY
endif endif
ifndef PY_CHECK_RUFF 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),) ifneq ($(PY_CHECK_RUFF),)
PY_CHECK_RUFF += --config $(TOPDIR)/pyproject.toml PY_CHECK_RUFF += --config $(TOPDIR)/pyproject.toml
endif endif
@ -38,7 +38,7 @@ ifndef PY_CHECK_YAPF
endif endif
ifndef PY_CHECK_PYRIGHT 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 TD_GENERATE_FILES += pyrightconfig.json
endif endif

View file

@ -6,7 +6,7 @@ ifneq ($(PYTHON_VERSION),)
else else
ifeq ($(PYTHON),) ifeq ($(PYTHON),)
#PYTHON := $(lastword $(shell /bin/bash -O extglob -c "ls -v /usr/bin/python[0-9].+([0-9])")) #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 endif
PYTHON_VERSION ?= $(patsubst python%,%,$(notdir $(PYTHON))) PYTHON_VERSION ?= $(patsubst python%,%,$(notdir $(PYTHON)))
endif endif