]> git.kaiwu.me - njs.git/commitdiff
auto/cc: Use portable/POSIX 'command -v' instead of 'which'
authorZurab Kvachadze <zurabid2016@gmail.com>
Mon, 26 Jan 2026 14:54:51 +0000 (15:54 +0100)
committerDmitry Volyntsev <xeioexception@gmail.com>
Mon, 26 Jan 2026 18:03:29 +0000 (10:03 -0800)
'which' is not a portable utility as it is not specified by POSIX. Since
auto/cc is already a shell script, use the more direct and portable
'command' builtin to detect $CC.

There are two bugs linked here. The first one is a downstream report of
this issue. The second one is more general information on why 'which'
usage is an issue and should be avoided.

Bug: https://bugs.gentoo.org/969288
Bug: https://bugs.gentoo.org/646588
Signed-off-by: Zurab Kvachadze <zurabid2016@gmail.com>
auto/cc

diff --git a/auto/cc b/auto/cc
index 8a615ec4a88ef1fbd0f8fdf9bcf592489c073957..5b21e17ea66e2e964e923424200aebed944cf951 100644 (file)
--- a/auto/cc
+++ b/auto/cc
@@ -13,7 +13,7 @@ END
 # Allow error exit status.
 set +e
 
-if [ -z "$(which $CC)" ]; then
+if ! command -v "${CC}" >/dev/null; then
     echo
     echo $0: error: $CC not found.
     echo