mirror of https://github.com/apache/maven.git
[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
This commit is contained in:
parent
0080e84588
commit
8852b87412
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue