@@ -17,6 +17,8 @@ export GRADLE_OPTS="-Dgradle.user.home=$GRADLE_USER_HOME"
1717# See the License for the specific language governing permissions and
1818# limitations under the License.
1919#
20+ # SPDX-License-Identifier: Apache-2.0
21+ #
2022
2123# #############################################################################
2224#
@@ -57,7 +59,7 @@ export GRADLE_OPTS="-Dgradle.user.home=$GRADLE_USER_HOME"
5759# Darwin, MinGW, and NonStop.
5860#
5961# (3) This script is generated from the Groovy template
60- # https://github.com/gradle/gradle/blob/master/subprojects/ plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
62+ # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/ plugins-application /src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
6163# within the Gradle project.
6264#
6365# You can find Gradle at https://github.com/gradle/gradle/.
8284 esac
8385done
8486
85- APP_HOME=$( cd " ${APP_HOME:- ./ } " && pwd -P ) || exit
86-
87- APP_NAME=" Gradle"
87+ # This is normally unused
88+ # shellcheck disable=SC2034
8889APP_BASE_NAME=${0##*/ }
89-
90- # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
91- DEFAULT_JVM_OPTS=' "-Xmx64m" "-Xms64m"'
90+ # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
91+ APP_HOME=$( cd -P " ${APP_HOME:- ./ } " > /dev/null && printf ' %s\n' " $PWD " ) || exit
9292
9393# Use the maximum available, or set MAX_FD != -1 to use that value.
9494MAX_FD=maximum
@@ -135,22 +135,29 @@ location of your Java installation."
135135 fi
136136else
137137 JAVACMD=java
138- which java > /dev/null 2>&1 || die " ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
138+ if ! command -v java > /dev/null 2>&1
139+ then
140+ die " ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
139141
140142Please set the JAVA_HOME variable in your environment to match the
141143location of your Java installation."
144+ fi
142145fi
143146
144147# Increase the maximum file descriptors if we can.
145148if ! " $cygwin " && ! " $darwin " && ! " $nonstop " ; then
146149 case $MAX_FD in # (
147150 max* )
151+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
152+ # shellcheck disable=SC2039,SC3045
148153 MAX_FD=$( ulimit -H -n ) ||
149154 warn " Could not query maximum file descriptor limit"
150155 esac
151156 case $MAX_FD in # (
152157 ' ' | soft) : ;; # (
153158 * )
159+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
160+ # shellcheck disable=SC2039,SC3045
154161 ulimit -n " $MAX_FD " ||
155162 warn " Could not set maximum file descriptor limit to $MAX_FD "
156163 esac
@@ -195,11 +202,15 @@ if "$cygwin" || "$msys" ; then
195202 done
196203fi
197204
198- # Collect all arguments for the java command;
199- # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
200- # shell script including quotes and variable substitutions, so put them in
201- # double quotes to make sure that they get re-expanded; and
202- # * put everything else in single quotes, so that it's not re-expanded.
205+
206+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
207+ DEFAULT_JVM_OPTS=' "-Xmx64m" "-Xms64m"'
208+
209+ # Collect all arguments for the java command:
210+ # * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
211+ # and any embedded shellness will be escaped.
212+ # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
213+ # treated as '${Hostname}' itself on the command line.
203214
204215set -- \
205216 " -Dorg.gradle.appname=$APP_BASE_NAME " \
0 commit comments