]> source.dussan.org Git - sonar-scanner-cli.git/commitdiff
[SCANCLI-153] Use shell alternative to `which`
authorVincent Latombe <vincent@latombe.net>
Thu, 29 Aug 2024 12:46:49 +0000 (14:46 +0200)
committerEric Giffon <eric.giffon@sonarsource.com>
Wed, 4 Sep 2024 10:24:18 +0000 (12:24 +0200)
`which` may or may not be available on host systems. There are
equivalent which are shell builtin.

This is essentially using the same as https://github.com/apache/maven/commit/8852b87412c0af70efcee76f1bb12bc44635aab1, which has proven to work fine on a large shell variety.

src/main/assembly/bin/sonar-scanner

index 128143f56a8c213cf1bffea3a493582153fa64d9..c344131237ad96f744346a43c852db12010acbbd 100755 (executable)
@@ -48,7 +48,7 @@ if [ -n "$JAVA_HOME" ]
 then
   java_cmd="$JAVA_HOME/bin/java"
 else
-  java_cmd="`which java`"
+  java_cmd="`\\unset -f command; \\command -v java`"
 fi
 
 if [ -z "$java_cmd" -o ! -x "$java_cmd" ] ; then