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:19:09 UTC

[maven] branch MNG-7270 created (now 8852b87)

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

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


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

This branch includes the following new commits:

     new 8852b87  [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
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 8852b87412c0af70efcee76f1bb12bc44635aab1
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/assembly/shared/init | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/apache-maven/src/assembly/shared/init b/apache-maven/src/assembly/shared/init
index fe8780b..619bc4d 100755
--- a/apache-maven/src/assembly/shared/init
+++ b/apache-maven/src/assembly/shared/init
@@ -20,7 +20,7 @@ if [ -n "$JAVA_HOME" ] ; then
     fi
   fi
 else
-  JAVACMD="`which java`"
+  JAVACMD="`\\unset -f command; \\command -v java`"
 
   if [ ! -x "$JAVACMD" ] ; then
     echo "The java(1) command does not exist in PATH nor is JAVA_HOME set, so Apache Maven cannot be started." >&2