1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

makefiles: Replace which with command -v

As the POSIX documentation[1] of `command -v` guarantees that on error
there will be no output (and there will be output in the other cases),
the tests in Makefiles were simplified to test for output equality to
the empty string.

Redirects swallowing error outputs were removed, as the command produces
no error output there (as recommended at [2]).

Existing uses of `command` are simplified as well.

[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html
[2]: https://salsa.debian.org/debian/debianutils/-/blob/master/debian/NEWS
This commit is contained in:
chrysn 2021-08-24 15:11:20 +02:00
parent ab6f24fb70
commit 6b50033766
7 changed files with 17 additions and 17 deletions

View File

@ -150,7 +150,7 @@ jobs:
TTN_DEV_ID="riot_lorawan_1" \
TTN_DEV_ID_ABP="riot_lorawan_1_abp" \
RIOTBASE=${RIOTBASE} \
$(which tox) -e test -- ${TOX_ARGS} \
$(command -v tox) -e test -- ${TOX_ARGS} \
${K} "${{ github.event.inputs.filter }}" -m "${{ matrix.pytest_mark }}"
- name: junit2html and XML deploy
if: always()

View File

@ -327,13 +327,13 @@ APPLICATION := $(strip $(APPLICATION))
ifeq (,$(and $(DOWNLOAD_TO_STDOUT),$(DOWNLOAD_TO_FILE)))
ifeq (,$(WGET))
ifeq (0,$(shell which wget > /dev/null 2>&1 ; echo $$?))
WGET = $(call memoized,WGET,$(shell which wget))
ifeq (,$(shell command -v wget))
WGET = $(call memoized,WGET,$(shell command -v wget))
endif
endif
ifeq (,$(CURL))
ifeq (0,$(shell which curl > /dev/null 2>&1 ; echo $$?))
CURL = $(call memoized,CURL,$(shell which curl))
ifneq (,$(shell command -v curl))
CURL = $(call memoized,CURL,$(shell command -v curl))
endif
endif
ifeq (,$(WGET)$(CURL))
@ -349,11 +349,11 @@ ifeq (,$(and $(DOWNLOAD_TO_STDOUT),$(DOWNLOAD_TO_FILE)))
endif
ifeq (,$(UNZIP_HERE))
ifeq (0,$(shell which unzip > /dev/null 2>&1 ; echo $$?))
UNZIP_HERE = $(call memoized,UNZIP_HERE,$(shell which unzip) -q)
ifneq (,$(shell command -v unzip))
UNZIP_HERE = $(call memoized,UNZIP_HERE,$(shell command -v unzip) -q)
else
ifeq (0,$(shell which 7z > /dev/null 2>&1 ; echo $$?))
UNZIP_HERE = $(call memoized,UNZIP_HERE,$(shell which 7z) x -bd)
ifneq (,$(shell command -v 7z))
UNZIP_HERE = $(call memoized,UNZIP_HERE,$(shell command -v 7z) x -bd)
else
$(warning Neither unzip nor 7z is installed.)
endif

View File

@ -57,7 +57,7 @@ endif
IOTLAB_AUTH ?= $(HOME)/.iotlabrc
IOTLAB_USER ?= $(shell cut -f1 -d: $(IOTLAB_AUTH))
ifneq (0,$(shell command -v iotlab-experiment -h 2>&1 > /dev/null ; echo $$?))
ifeq (,$(shell command -v iotlab-experiment))
$(info $(COLOR_RED)'iotlab-experiment' command is not available \
please consider installing it from \
https://pypi.python.org/pypi/iotlabcli$(COLOR_RESET))
@ -66,7 +66,7 @@ endif
ifeq (iotlab-a8-m3,$(BOARD))
ifneq (,$(filter flash% reset,$(MAKECMDGOALS)))
ifneq (0,$(shell command -v iotlab-ssh -h 2>&1 > /dev/null ; echo $$?))
ifeq (,$(shell command -v iotlab-ssh))
$(info $(COLOR_RED)'iotlab-ssh' command is not available \
please consider installing it from \
https://pypi.python.org/pypi/iotlabsshcli$(COLOR_RESET))

View File

@ -34,9 +34,9 @@
#
# Use full path in case it needs to be run with sudo
OPENV_SERVER_PATH := $(shell which openv-server)
OPENV_CLIENT_PATH := $(shell which openv-client)
OPENV_SERIAL_PATH := $(shell which openv-serial)
OPENV_SERVER_PATH := $(shell command -v openv-server)
OPENV_CLIENT_PATH := $(shell command -v openv-client)
OPENV_SERIAL_PATH := $(shell command -v openv-serial)
# Openvisualizer requires to know where openwsn-fw is located
OPENV_OPENWSN_FW_PATH ?= --fw-path=$(RIOTBASE)/build/pkg/openwsn

View File

@ -25,7 +25,7 @@ TARGET_ARCH_RISCV ?= \
$(subst -gcc,,\
$(notdir \
$(word 1,\
$(foreach triple,$(_TRIPLES_TO_TEST),$(shell which $(triple)-gcc 2> /dev/null))))))
$(foreach triple,$(_TRIPLES_TO_TEST),$(shell command -v $(triple)-gcc))))))
TARGET_ARCH ?= $(TARGET_ARCH_RISCV)

View File

@ -29,7 +29,7 @@ ifeq ($(PROGRAMMER),)
PROGRAMMER ?= edbg
else ifeq ($(OPENOCD_DEBUG_ADAPTER),jlink)
# only use JLinkExe if it's installed
ifneq (,$(shell which JLinkExe))
ifneq (,$(shell command -v JLinkExe))
PROGRAMMER ?= jlink
else
PROGRAMMER ?= openocd

View File

@ -2,7 +2,7 @@ INCLUDES += -I$(PKGDIRBASE)/flatbuffers/include
FLATC ?= flatc
ifneq (0,$(shell which flatc > /dev/null 2>&1 ; echo $$?))
ifeq (,$(shell command -v flatc ))
FLATC = $(RIOTTOOLS)/flatc/flatc
$(call target-export-variables,all,FLATC)
endif