55
55
# Darwin, MinGW, and NonStop.
56
56
#
57
57
# (3) This script is generated from the Groovy template
58
- # https://github.com/gradle/gradle/blob/master /subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
58
+ # https://github.com/gradle/gradle/blob/HEAD /subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59
59
# within the Gradle project.
60
60
#
61
61
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -69,37 +69,35 @@ app_path=$0
69
69
70
70
# Need this for daisy-chained symlinks.
71
71
while
72
- APP_HOME=${app_path% " ${app_path##*/ } " } # leaves a trailing /; empty if no leading path
73
- [ -h " $app_path " ]
72
+ APP_HOME=${app_path% " ${app_path##*/ } " } # leaves a trailing /; empty if no leading path
73
+ [ -h " $app_path " ]
74
74
do
75
- ls=$( ls -ld " $app_path " )
76
- link=${ls#* ' -> ' }
77
- case $link in # (
78
- /* ) app_path=$link ;; # (
79
- * ) app_path=$APP_HOME$link ;;
80
- esac
75
+ ls=$( ls -ld " $app_path " )
76
+ link=${ls#* ' -> ' }
77
+ case $link in # (
78
+ /* ) app_path=$link ;; # (
79
+ * ) app_path=$APP_HOME$link ;;
80
+ esac
81
81
done
82
82
83
- APP_HOME=$( cd " ${APP_HOME:- ./ } " && pwd -P ) || exit
84
-
85
- APP_NAME=" Gradle"
83
+ # This is normally unused
84
+ # shellcheck disable=SC2034
86
85
APP_BASE_NAME=${0##*/ }
87
-
88
- # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89
- DEFAULT_JVM_OPTS=' -Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"'
86
+ # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87
+ APP_HOME=$( cd " ${APP_HOME:- ./ } " > /dev/null && pwd -P ) || exit
90
88
91
89
# Use the maximum available, or set MAX_FD != -1 to use that value.
92
90
MAX_FD=maximum
93
91
94
92
warn () {
95
- echo " $* "
93
+ echo " $* "
96
94
} >&2
97
95
98
96
die () {
99
- echo
100
- echo " $* "
101
- echo
102
- exit 1
97
+ echo
98
+ echo " $* "
99
+ echo
100
+ exit 1
103
101
} >&2
104
102
105
103
# OS specific support (must be 'true' or 'false').
@@ -108,50 +106,57 @@ msys=false
108
106
darwin=false
109
107
nonstop=false
110
108
case " $( uname ) " in # (
111
- CYGWIN* ) cygwin=true ;; # (
112
- Darwin* ) darwin=true ;; # (
113
- MSYS* | MINGW* ) msys=true ;; # (
114
- NONSTOP* ) nonstop=true ;;
109
+ CYGWIN* ) cygwin=true ;; # (
110
+ Darwin* ) darwin=true ;; # (
111
+ MSYS* | MINGW* ) msys=true ;; # (
112
+ NONSTOP* ) nonstop=true ;;
115
113
esac
116
114
117
115
CLASSPATH=$APP_HOME /gradle/wrapper/gradle-wrapper.jar
118
116
119
117
120
118
# Determine the Java command to use to start the JVM.
121
119
if [ -n " $JAVA_HOME " ] ; then
122
- if [ -x " $JAVA_HOME /jre/sh/java" ] ; then
123
- # IBM's JDK on AIX uses strange locations for the executables
124
- JAVACMD=$JAVA_HOME /jre/sh/java
125
- else
126
- JAVACMD=$JAVA_HOME /bin/java
127
- fi
128
- if [ ! -x " $JAVACMD " ] ; then
129
- die " ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
120
+ if [ -x " $JAVA_HOME /jre/sh/java" ] ; then
121
+ # IBM's JDK on AIX uses strange locations for the executables
122
+ JAVACMD=$JAVA_HOME /jre/sh/java
123
+ else
124
+ JAVACMD=$JAVA_HOME /bin/java
125
+ fi
126
+ if [ ! -x " $JAVACMD " ] ; then
127
+ die " ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130
128
131
129
Please set the JAVA_HOME variable in your environment to match the
132
130
location of your Java installation."
133
- fi
131
+ fi
134
132
else
135
- JAVACMD=java
136
- which java > /dev/null 2>&1 || die " ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
133
+ JAVACMD=java
134
+ if ! command -v java > /dev/null 2>&1
135
+ then
136
+ die " ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137
137
138
138
Please set the JAVA_HOME variable in your environment to match the
139
139
location of your Java installation."
140
140
fi
141
+ fi
141
142
142
143
# Increase the maximum file descriptors if we can.
143
144
if ! " $cygwin " && ! " $darwin " && ! " $nonstop " ; then
144
- case $MAX_FD in # (
145
- max* )
146
- MAX_FD=$( ulimit -H -n ) ||
147
- warn " Could not query maximum file descriptor limit"
148
- esac
149
- case $MAX_FD in # (
150
- ' ' | soft) : ;; # (
151
- * )
152
- ulimit -n " $MAX_FD " ||
153
- warn " Could not set maximum file descriptor limit to $MAX_FD "
154
- esac
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
+ esac
152
+ case $MAX_FD in # (
153
+ ' ' | soft) : ;; # (
154
+ * )
155
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
156
+ # shellcheck disable=SC2039,SC3045
157
+ ulimit -n " $MAX_FD " ||
158
+ warn " Could not set maximum file descriptor limit to $MAX_FD "
159
+ esac
155
160
fi
156
161
157
162
# Collect all arguments for the java command, stacking in reverse order:
164
169
165
170
# For Cygwin or MSYS, switch paths to Windows format before running java
166
171
if " $cygwin " || " $msys " ; then
167
- APP_HOME=$( cygpath --path --mixed " $APP_HOME " )
168
- CLASSPATH=$( cygpath --path --mixed " $CLASSPATH " )
169
-
170
- JAVACMD=$( cygpath --unix " $JAVACMD " )
171
-
172
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
173
- for arg do
174
- if
175
- case $arg in # (
176
- -* ) false ;; # don't mess with options #(
177
- /?* ) t=${arg#/ } t=/${t%%/* } # looks like a POSIX filepath
178
- [ -e " $t " ] ;; # (
179
- * ) false ;;
180
- esac
181
- then
182
- arg=$( cygpath --path --ignore --mixed " $arg " )
183
- fi
184
- # Roll the args list around exactly as many times as the number of
185
- # args, so each arg winds up back in the position where it started, but
186
- # possibly modified.
187
- #
188
- # NB: a `for` loop captures its iteration list before it begins, so
189
- # changing the positional parameters here affects neither the number of
190
- # iterations, nor the values presented in `arg`.
191
- shift # remove old arg
192
- set -- " $@ " " $arg " # push replacement arg
193
- done
172
+ APP_HOME=$( cygpath --path --mixed " $APP_HOME " )
173
+ CLASSPATH=$( cygpath --path --mixed " $CLASSPATH " )
174
+
175
+ JAVACMD=$( cygpath --unix " $JAVACMD " )
176
+
177
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
178
+ for arg do
179
+ if
180
+ case $arg in # (
181
+ -* ) false ;; # don't mess with options #(
182
+ /?* ) t=${arg#/ } t=/${t%%/* } # looks like a POSIX filepath
183
+ [ -e " $t " ] ;; # (
184
+ * ) false ;;
185
+ esac
186
+ then
187
+ arg=$( cygpath --path --ignore --mixed " $arg " )
188
+ fi
189
+ # Roll the args list around exactly as many times as the number of
190
+ # args, so each arg winds up back in the position where it started, but
191
+ # possibly modified.
192
+ #
193
+ # NB: a `for` loop captures its iteration list before it begins, so
194
+ # changing the positional parameters here affects neither the number of
195
+ # iterations, nor the values presented in `arg`.
196
+ shift # remove old arg
197
+ set -- " $@ " " $arg " # push replacement arg
198
+ done
194
199
fi
195
200
196
- # Collect all arguments for the java command;
197
- # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198
- # shell script including quotes and variable substitutions, so put them in
199
- # double quotes to make sure that they get re-expanded; and
200
- # * put everything else in single quotes, so that it's not re-expanded.
201
+
202
+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203
+ DEFAULT_JVM_OPTS=' "-Xmx64m" "-Xms64m"'
204
+
205
+ # Collect all arguments for the java command:
206
+ # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207
+ # and any embedded shellness will be escaped.
208
+ # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209
+ # treated as '${Hostname}' itself on the command line.
201
210
202
211
set -- \
203
- " -Dorg.gradle.appname=$APP_BASE_NAME " \
204
- -classpath " $CLASSPATH " \
205
- org.gradle.wrapper.GradleWrapperMain \
206
- " $@ "
212
+ " -Dorg.gradle.appname=$APP_BASE_NAME " \
213
+ -classpath " $CLASSPATH " \
214
+ org.gradle.wrapper.GradleWrapperMain \
215
+ " $@ "
216
+
217
+ # Stop when "xargs" is not available.
218
+ if ! command -v xargs > /dev/null 2>&1
219
+ then
220
+ die " xargs is not available"
221
+ fi
207
222
208
223
# Use "xargs" to parse quoted args.
209
224
#
@@ -225,10 +240,10 @@ set -- \
225
240
#
226
241
227
242
eval " set -- $(
228
- printf ' %s\n' " $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS " |
229
- xargs -n1 |
230
- sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
231
- tr ' \n' ' '
232
- ) " ' "$@"'
243
+ printf ' %s\n' " $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS " |
244
+ xargs -n1 |
245
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
246
+ tr ' \n' ' '
247
+ ) " ' "$@"'
233
248
234
249
exec " $JAVACMD " " $@ "
0 commit comments