@@ -71,95 +71,94 @@ app_path=$0
7171
7272# Need this for daisy-chained symlinks.
7373while
74- APP_HOME=${app_path% " ${app_path##*/ } " } # leaves a trailing /; empty if no leading path
75- [ -h " $app_path " ]
74+ APP_HOME=${app_path% " ${app_path##*/ } " } # leaves a trailing /; empty if no leading path
75+ [ -h " $app_path " ]
7676do
77- ls=$( ls -ld " $app_path " )
78- link=${ls#* ' -> ' }
79- case $link in # (
80- /* ) app_path=$link ;; # (
81- * ) app_path=$APP_HOME$link ;;
82- esac
77+ ls=$( ls -ld " $app_path " )
78+ link=${ls#* ' -> ' }
79+ case $link in # (
80+ /* ) app_path=$link ;; # (
81+ * ) app_path=$APP_HOME$link ;;
82+ esac
8383done
8484
8585# This is normally unused
8686# shellcheck disable=SC2034
8787APP_BASE_NAME=${0##*/ }
8888# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89- APP_HOME=$( cd -P " ${APP_HOME:- ./ } " > /dev/null && printf ' %s
90- ' " $PWD " ) || exit
89+ APP_HOME=$( cd -P " ${APP_HOME:- ./ } " > /dev/null && printf ' %s\n' " $PWD " ) || exit
9190
9291# Use the maximum available, or set MAX_FD != -1 to use that value.
9392MAX_FD=maximum
9493
95- warn () {
96- echo " $* "
94+ warn () {
95+ echo " $* "
9796} >&2
9897
99- die () {
100- echo
101- echo " $* "
102- echo
103- exit 1
98+ die () {
99+ echo
100+ echo " $* "
101+ echo
102+ exit 1
104103} >&2
105104
106105# OS specific support (must be 'true' or 'false').
107106cygwin=false
108107msys=false
109108darwin=false
110109nonstop=false
111- case " $( uname ) " in # (
112- CYGWIN* ) cygwin=true ;; # (
113- Darwin* ) darwin=true ;; # (
114- MSYS* | MINGW* ) msys=true ;; # (
115- NONSTOP* ) nonstop=true ;;
110+ case " $( uname) " in # (
111+ CYGWIN* ) cygwin=true ;; # (
112+ Darwin* ) darwin=true ;; # (
113+ MSYS* | MINGW* ) msys=true ;; # (
114+ NONSTOP* ) nonstop=true ;;
116115esac
117116
118117CLASSPATH=$APP_HOME /gradle/wrapper/gradle-wrapper.jar
119118
120-
121119# Determine the Java command to use to start the JVM.
122- if [ -n " $JAVA_HOME " ] ; then
123- if [ -x " $JAVA_HOME /jre/sh/java" ] ; then
124- # IBM's JDK on AIX uses strange locations for the executables
125- JAVACMD=$JAVA_HOME /jre/sh/java
126- else
127- JAVACMD=$JAVA_HOME /bin/java
128- fi
129- if [ ! -x " $JAVACMD " ] ; then
130- die " ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
120+ if [ -n " $JAVA_HOME " ]; then
121+ if [ -x " $JAVA_HOME /jre/sh/java" ]; then
122+ # IBM's JDK on AIX uses strange locations for the executables
123+ JAVACMD=$JAVA_HOME /jre/sh/java
124+ else
125+ JAVACMD=$JAVA_HOME /bin/java
126+ fi
127+ if [ ! -x " $JAVACMD " ]; then
128+ die " ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
131129
132130Please set the JAVA_HOME variable in your environment to match the
133131location of your Java installation."
134- fi
132+ fi
135133else
136- JAVACMD=java
137- if ! command -v java > /dev/null 2>&1
138- then
139- die " ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
134+ JAVACMD=java
135+ if ! command -v java > /dev/null 2>&1 ; then
136+ die " ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
140137
141138Please set the JAVA_HOME variable in your environment to match the
142139location of your Java installation."
143- fi
140+ fi
144141fi
145142
146143# Increase the maximum file descriptors if we can.
147- if ! " $cygwin " && ! " $darwin " && ! " $nonstop " ; then
148- case $MAX_FD in # (
149- max* )
150- # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
151- # shellcheck disable=SC2039,SC3045
152- MAX_FD=$( ulimit -H -n ) ||
153- warn " Could not query maximum file descriptor limit"
154- esac
155- case $MAX_FD in # (
156- ' ' | soft) : ;; # (
157- * )
158- # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
159- # shellcheck disable=SC2039,SC3045
160- ulimit -n " $MAX_FD " ||
161- warn " Could not set maximum file descriptor limit to $MAX_FD "
162- esac
144+ if ! " $cygwin " && ! " $darwin " && ! " $nonstop " ; then
145+ case $MAX_FD in # (
146+ max* )
147+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
148+ # shellcheck disable=SC2039,SC3045
149+ MAX_FD=$( ulimit -H -n) ||
150+ warn " Could not query maximum file descriptor limit"
151+ ;;
152+ esac
153+ case $MAX_FD in # (
154+ ' ' | soft) : ;; # (
155+ * )
156+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
157+ # shellcheck disable=SC2039,SC3045
158+ ulimit -n " $MAX_FD " ||
159+ warn " Could not set maximum file descriptor limit to $MAX_FD "
160+ ;;
161+ esac
163162fi
164163
165164# Collect all arguments for the java command, stacking in reverse order:
171170# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
172171
173172# For Cygwin or MSYS, switch paths to Windows format before running java
174- if " $cygwin " || " $msys " ; then
175- APP_HOME=$( cygpath --path --mixed " $APP_HOME " )
176- CLASSPATH=$( cygpath --path --mixed " $CLASSPATH " )
177-
178- JAVACMD=$( cygpath --unix " $JAVACMD " )
179-
180- # Now convert the arguments - kludge to limit ourselves to /bin/sh
181- for arg do
182- if
183- case $arg in # (
184- -* ) false ;; # don't mess with options #(
185- /?* ) t=${arg#/ } t=/${t%%/* } # looks like a POSIX filepath
186- [ -e " $t " ] ;; # (
187- * ) false ;;
188- esac
189- then
190- arg=$( cygpath --path --ignore --mixed " $arg " )
191- fi
192- # Roll the args list around exactly as many times as the number of
193- # args, so each arg winds up back in the position where it started, but
194- # possibly modified.
195- #
196- # NB: a `for` loop captures its iteration list before it begins, so
197- # changing the positional parameters here affects neither the number of
198- # iterations, nor the values presented in `arg`.
199- shift # remove old arg
200- set -- " $@ " " $arg " # push replacement arg
201- done
173+ if " $cygwin " || " $msys " ; then
174+ APP_HOME=$( cygpath --path --mixed " $APP_HOME " )
175+ CLASSPATH=$( cygpath --path --mixed " $CLASSPATH " )
176+
177+ JAVACMD=$( cygpath --unix " $JAVACMD " )
178+
179+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
180+ for arg; do
181+ if
182+ case $arg in # (
183+ -* ) false ;; # don't mess with options #(
184+ /?* )
185+ t=${arg#/ } t=/${t%%/* } # looks like a POSIX filepath
186+ [ -e " $t " ]
187+ ;; # (
188+ * ) false ;;
189+ esac
190+ then
191+ arg=$( cygpath --path --ignore --mixed " $arg " )
192+ fi
193+ # Roll the args list around exactly as many times as the number of
194+ # args, so each arg winds up back in the position where it started, but
195+ # possibly modified.
196+ #
197+ # NB: a `for` loop captures its iteration list before it begins, so
198+ # changing the positional parameters here affects neither the number of
199+ # iterations, nor the values presented in `arg`.
200+ shift # remove old arg
201+ set -- " $@ " " $arg " # push replacement arg
202+ done
202203fi
203204
204-
205205# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
206206DEFAULT_JVM_OPTS=' "-Xmx64m" "-Xms64m"'
207207
208208# Collect all arguments for the java command:
209- # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
209+ # * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
210210# and any embedded shellness will be escaped.
211211# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
212212# treated as '${Hostname}' itself on the command line.
213213
214214set -- \
215- " -Dorg.gradle.appname=$APP_BASE_NAME " \
216- -classpath " $CLASSPATH " \
217- org.gradle.wrapper.GradleWrapperMain \
218- " $@ "
215+ " -Dorg.gradle.appname=$APP_BASE_NAME " \
216+ -classpath " $CLASSPATH " \
217+ org.gradle.wrapper.GradleWrapperMain \
218+ " $@ "
219219
220220# Stop when "xargs" is not available.
221- if ! command -v xargs > /dev/null 2>&1
222- then
223- die " xargs is not available"
221+ if ! command -v xargs > /dev/null 2>&1 ; then
222+ die " xargs is not available"
224223fi
225224
226225# Use "xargs" to parse quoted args.
243242#
244243
245244eval " set -- $(
246- printf ' %s\n' " $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS " |
247- xargs -n1 |
248- sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
249- tr ' \n' ' '
250- ) " ' "$@"'
245+ printf ' %s\n' " $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS " |
246+ xargs -n1 |
247+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
248+ tr ' \n' ' '
249+ ) " ' "$@"'
251250
252251exec " $JAVACMD " " $@ "
0 commit comments