You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2021/10/11 20:51:39 UTC

[maven] branch MNG-7270-maven-3.8.x created (now fb5f3f5)

This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a change to branch MNG-7270-maven-3.8.x
in repository https://gitbox.apache.org/repos/asf/maven.git.


      at fb5f3f5  [MNG-7270] Switch to shell alternative to "which"

This branch includes the following new commits:

     new fb5f3f5  [MNG-7270] Switch to shell alternative to "which"

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[maven] 01/01: [MNG-7270] Switch to shell alternative to "which"

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch MNG-7270-maven-3.8.x
in repository https://gitbox.apache.org/repos/asf/maven.git

commit fb5f3f5b0f36d3232b0193c1d9b33fd0b36b9601
Author: Jonathan Dowland <jd...@redhat.com>
AuthorDate: Wed Sep 29 11:29:35 2021 +0100

    [MNG-7270] Switch to shell alternative to "which"
    
    In some circumstances the init script calls `which`, which may or may not be
    available on the host system. Instead, use `command -v`, which is nearly
    equivalent. One area it differs is if the command being queried is defined as
    a shell alias. To avoid that, call `unset -f command` to avoid the situation
    where "command" has been re-defined as a shell function.
    
    See here for more information on this approach:
    <https://pubs.opengroup.org/onlinepubs/009695399/utilities/command.html>
    
    Tested with bash, sh (bash invoked as sh), posh, dash, zsh and mksh.
    
    This closes #556
---
 apache-maven/src/bin/mvn | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/apache-maven/src/bin/mvn b/apache-maven/src/bin/mvn
index 90f9a75..dfa384b 100755
--- a/apache-maven/src/bin/mvn
+++ b/apache-maven/src/bin/mvn
@@ -94,7 +94,7 @@ if $mingw ; then
 fi
 
 if [ -z "$JAVA_HOME" ] ; then
-  JAVACMD=`which java`
+  JAVACMD="`\\unset -f command; \\command -v java`"
 else
   JAVACMD="$JAVA_HOME/bin/java"
 fi