···11-#!/usr/bin/env sh
11+#!/bin/sh
2233#
44-# Copyright 2015 the original author or authors.
44+# Copyright � 2015-2021 the original authors.
55#
66# Licensed under the Apache License, Version 2.0 (the "License");
77# you may not use this file except in compliance with the License.
···1717#
18181919##############################################################################
2020-##
2121-## Gradle start up script for UN*X
2222-##
2020+#
2121+# Gradle start up script for POSIX generated by Gradle.
2222+#
2323+# Important for running:
2424+#
2525+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
2626+# noncompliant, but you have some other compliant shell such as ksh or
2727+# bash, then to run this script, type that shell name before the whole
2828+# command line, like:
2929+#
3030+# ksh Gradle
3131+#
3232+# Busybox and similar reduced shells will NOT work, because this script
3333+# requires all of these POSIX shell features:
3434+# * functions;
3535+# * expansions �$var�, �${var}�, �${var:-default}�, �${var+SET}�,
3636+# �${var#prefix}�, �${var%suffix}�, and �$( cmd )�;
3737+# * compound commands having a testable exit status, especially �case�;
3838+# * various built-in commands including �command�, �set�, and �ulimit�.
3939+#
4040+# Important for patching:
4141+#
4242+# (2) This script targets any POSIX shell, so it avoids extensions provided
4343+# by Bash, Ksh, etc; in particular arrays are avoided.
4444+#
4545+# The "traditional" practice of packing multiple parameters into a
4646+# space-separated string is a well documented source of bugs and security
4747+# problems, so this is (mostly) avoided, by progressively accumulating
4848+# options in "$@", and eventually passing that to Java.
4949+#
5050+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
5151+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
5252+# see the in-line comments for details.
5353+#
5454+# There are tweaks for specific operating systems such as AIX, CygWin,
5555+# Darwin, MinGW, and NonStop.
5656+#
5757+# (3) This script is generated from the Groovy template
5858+# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5959+# within the Gradle project.
6060+#
6161+# You can find Gradle at https://github.com/gradle/gradle/.
6262+#
2363##############################################################################
24642565# Attempt to set APP_HOME
6666+2667# Resolve links: $0 may be a link
2727-PRG="$0"
2828-# Need this for relative symlinks.
2929-while [ -h "$PRG" ] ; do
3030- ls=`ls -ld "$PRG"`
3131- link=`expr "$ls" : '.*-> \(.*\)$'`
3232- if expr "$link" : '/.*' > /dev/null; then
3333- PRG="$link"
3434- else
3535- PRG=`dirname "$PRG"`"/$link"
3636- fi
6868+app_path=$0
6969+7070+# Need this for daisy-chained symlinks.
7171+while
7272+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
7373+ [ -h "$app_path" ]
7474+do
7575+ ls=$( ls -ld "$app_path" )
7676+ link=${ls#*' -> '}
7777+ case $link in #(
7878+ /*) app_path=$link ;; #(
7979+ *) app_path=$APP_HOME$link ;;
8080+ esac
3781done
3838-SAVED="`pwd`"
3939-cd "`dirname \"$PRG\"`/" >/dev/null
4040-APP_HOME="`pwd -P`"
4141-cd "$SAVED" >/dev/null
8282+8383+APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
42844385APP_NAME="Gradle"
4444-APP_BASE_NAME=`basename "$0"`
8686+APP_BASE_NAME=${0##*/}
45874688# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
4789DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48904991# Use the maximum available, or set MAX_FD != -1 to use that value.
5050-MAX_FD="maximum"
9292+MAX_FD=maximum
51935294warn () {
5395 echo "$*"
5454-}
9696+} >&2
55975698die () {
5799 echo
58100 echo "$*"
59101 echo
60102 exit 1
6161-}
103103+} >&2
6210463105# OS specific support (must be 'true' or 'false').
64106cygwin=false
65107msys=false
66108darwin=false
67109nonstop=false
6868-case "`uname`" in
6969- CYGWIN* )
7070- cygwin=true
7171- ;;
7272- Darwin* )
7373- darwin=true
7474- ;;
7575- MSYS* | MINGW* )
7676- msys=true
7777- ;;
7878- NONSTOP* )
7979- nonstop=true
8080- ;;
110110+case "$( uname )" in #(
111111+ CYGWIN* ) cygwin=true ;; #(
112112+ Darwin* ) darwin=true ;; #(
113113+ MSYS* | MINGW* ) msys=true ;; #(
114114+ NONSTOP* ) nonstop=true ;;
81115esac
8211683117CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
···87121if [ -n "$JAVA_HOME" ] ; then
88122 if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89123 # IBM's JDK on AIX uses strange locations for the executables
9090- JAVACMD="$JAVA_HOME/jre/sh/java"
124124+ JAVACMD=$JAVA_HOME/jre/sh/java
91125 else
9292- JAVACMD="$JAVA_HOME/bin/java"
126126+ JAVACMD=$JAVA_HOME/bin/java
93127 fi
94128 if [ ! -x "$JAVACMD" ] ; then
95129 die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
···98132location of your Java installation."
99133 fi
100134else
101101- JAVACMD="java"
135135+ JAVACMD=java
102136 which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103137104138Please set the JAVA_HOME variable in your environment to match the
···106140fi
107141108142# Increase the maximum file descriptors if we can.
109109-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110110- MAX_FD_LIMIT=`ulimit -H -n`
111111- if [ $? -eq 0 ] ; then
112112- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113113- MAX_FD="$MAX_FD_LIMIT"
114114- fi
115115- ulimit -n $MAX_FD
116116- if [ $? -ne 0 ] ; then
117117- warn "Could not set maximum file descriptor limit: $MAX_FD"
118118- fi
119119- else
120120- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121121- fi
143143+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144144+ case $MAX_FD in #(
145145+ max*)
146146+ MAX_FD=$( ulimit -H -n ) ||
147147+ warn "Could not query maximum file descriptor limit"
148148+ esac
149149+ case $MAX_FD in #(
150150+ '' | soft) :;; #(
151151+ *)
152152+ ulimit -n "$MAX_FD" ||
153153+ warn "Could not set maximum file descriptor limit to $MAX_FD"
154154+ esac
122155fi
123156124124-# For Darwin, add options to specify how the application appears in the dock
125125-if $darwin; then
126126- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127127-fi
157157+# Collect all arguments for the java command, stacking in reverse order:
158158+# * args from the command line
159159+# * the main class name
160160+# * -classpath
161161+# * -D...appname settings
162162+# * --module-path (only if needed)
163163+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
128164129165# For Cygwin or MSYS, switch paths to Windows format before running java
130130-if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131131- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132132- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
166166+if "$cygwin" || "$msys" ; then
167167+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
168168+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
133169134134- JAVACMD=`cygpath --unix "$JAVACMD"`
170170+ JAVACMD=$( cygpath --unix "$JAVACMD" )
135171136136- # We build the pattern for arguments to be converted via cygpath
137137- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138138- SEP=""
139139- for dir in $ROOTDIRSRAW ; do
140140- ROOTDIRS="$ROOTDIRS$SEP$dir"
141141- SEP="|"
142142- done
143143- OURCYGPATTERN="(^($ROOTDIRS))"
144144- # Add a user-defined pattern to the cygpath arguments
145145- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146146- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147147- fi
148172 # Now convert the arguments - kludge to limit ourselves to /bin/sh
149149- i=0
150150- for arg in "$@" ; do
151151- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152152- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153153-154154- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155155- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156156- else
157157- eval `echo args$i`="\"$arg\""
173173+ for arg do
174174+ if
175175+ case $arg in #(
176176+ -*) false ;; # don't mess with options #(
177177+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
178178+ [ -e "$t" ] ;; #(
179179+ *) false ;;
180180+ esac
181181+ then
182182+ arg=$( cygpath --path --ignore --mixed "$arg" )
158183 fi
159159- i=`expr $i + 1`
184184+ # Roll the args list around exactly as many times as the number of
185185+ # args, so each arg winds up back in the position where it started, but
186186+ # possibly modified.
187187+ #
188188+ # NB: a `for` loop captures its iteration list before it begins, so
189189+ # changing the positional parameters here affects neither the number of
190190+ # iterations, nor the values presented in `arg`.
191191+ shift # remove old arg
192192+ set -- "$@" "$arg" # push replacement arg
160193 done
161161- case $i in
162162- 0) set -- ;;
163163- 1) set -- "$args0" ;;
164164- 2) set -- "$args0" "$args1" ;;
165165- 3) set -- "$args0" "$args1" "$args2" ;;
166166- 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167167- 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168168- 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169169- 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170170- 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171171- 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172172- esac
173194fi
174195175175-# Escape application args
176176-save () {
177177- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178178- echo " "
179179-}
180180-APP_ARGS=`save "$@"`
196196+# Collect all arguments for the java command;
197197+# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198198+# shell script including quotes and variable substitutions, so put them in
199199+# double quotes to make sure that they get re-expanded; and
200200+# * put everything else in single quotes, so that it's not re-expanded.
201201+202202+set -- \
203203+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
204204+ -classpath "$CLASSPATH" \
205205+ org.gradle.wrapper.GradleWrapperMain \
206206+ "$@"
207207+208208+# Use "xargs" to parse quoted args.
209209+#
210210+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
211211+#
212212+# In Bash we could simply go:
213213+#
214214+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
215215+# set -- "${ARGS[@]}" "$@"
216216+#
217217+# but POSIX shell has neither arrays nor command substitution, so instead we
218218+# post-process each arg (as a line of input to sed) to backslash-escape any
219219+# character that might be a shell metacharacter, then use eval to reverse
220220+# that process (while maintaining the separation between arguments), and wrap
221221+# the whole thing up as a single "set" statement.
222222+#
223223+# This will of course break if any of these variables contains a newline or
224224+# an unmatched quote.
225225+#
181226182182-# Collect all arguments for the java command, following the shell quoting and substitution rules
183183-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
227227+eval "set -- $(
228228+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
229229+ xargs -n1 |
230230+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
231231+ tr '\n' ' '
232232+ )" '"$@"'
184233185234exec "$JAVACMD" "$@"