|  | 
| 15 | 15 | # See the License for the specific language governing permissions and | 
| 16 | 16 | # limitations under the License. | 
| 17 | 17 | # | 
|  | 18 | +# SPDX-License-Identifier: Apache-2.0 | 
|  | 19 | +# | 
| 18 | 20 | 
 | 
| 19 | 21 | ############################################################################## | 
| 20 | 22 | # | 
|  | 
| 55 | 57 | #       Darwin, MinGW, and NonStop. | 
| 56 | 58 | # | 
| 57 | 59 | #   (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 | 
|  | 60 | +#       https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt | 
| 59 | 61 | #       within the Gradle project. | 
| 60 | 62 | # | 
| 61 | 63 | #       You can find Gradle at https://github.com/gradle/gradle/. | 
|  | 
| 80 | 82 |     esac | 
| 81 | 83 | done | 
| 82 | 84 | 
 | 
| 83 |  | -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit | 
| 84 |  | - | 
| 85 |  | -APP_NAME="Gradle" | 
|  | 85 | +# This is normally unused | 
|  | 86 | +# shellcheck disable=SC2034 | 
| 86 | 87 | 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='"-Xmx64m" "-Xms64m"' | 
|  | 88 | +# 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 | 
| 90 | 91 | 
 | 
| 91 | 92 | # Use the maximum available, or set MAX_FD != -1 to use that value. | 
| 92 | 93 | MAX_FD=maximum | 
| @@ -133,22 +134,29 @@ location of your Java installation." | 
| 133 | 134 |     fi | 
| 134 | 135 | else | 
| 135 | 136 |     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. | 
|  | 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. | 
| 137 | 140 | 
 | 
| 138 | 141 | Please set the JAVA_HOME variable in your environment to match the | 
| 139 | 142 | location of your Java installation." | 
|  | 143 | +    fi | 
| 140 | 144 | fi | 
| 141 | 145 | 
 | 
| 142 | 146 | # Increase the maximum file descriptors if we can. | 
| 143 | 147 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then | 
| 144 | 148 |     case $MAX_FD in #( | 
| 145 | 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 | 
| 146 | 152 |         MAX_FD=$( ulimit -H -n ) || | 
| 147 | 153 |             warn "Could not query maximum file descriptor limit" | 
| 148 | 154 |     esac | 
| 149 | 155 |     case $MAX_FD in  #( | 
| 150 | 156 |       '' | soft) :;; #( | 
| 151 | 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 | 
| 152 | 160 |         ulimit -n "$MAX_FD" || | 
| 153 | 161 |             warn "Could not set maximum file descriptor limit to $MAX_FD" | 
| 154 | 162 |     esac | 
| @@ -193,18 +201,28 @@ if "$cygwin" || "$msys" ; then | 
| 193 | 201 |     done | 
| 194 | 202 | fi | 
| 195 | 203 | 
 | 
| 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. | 
|  | 204 | + | 
|  | 205 | +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | 
|  | 206 | +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' | 
|  | 207 | + | 
|  | 208 | +# Collect all arguments for the java command: | 
|  | 209 | +#   * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, | 
|  | 210 | +#     and any embedded shellness will be escaped. | 
|  | 211 | +#   * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be | 
|  | 212 | +#     treated as '${Hostname}' itself on the command line. | 
| 201 | 213 | 
 | 
| 202 | 214 | set -- \ | 
| 203 | 215 |         "-Dorg.gradle.appname=$APP_BASE_NAME" \ | 
| 204 | 216 |         -classpath "$CLASSPATH" \ | 
| 205 | 217 |         org.gradle.wrapper.GradleWrapperMain \ | 
| 206 | 218 |         "$@" | 
| 207 | 219 | 
 | 
|  | 220 | +# Stop when "xargs" is not available. | 
|  | 221 | +if ! command -v xargs >/dev/null 2>&1 | 
|  | 222 | +then | 
|  | 223 | +    die "xargs is not available" | 
|  | 224 | +fi | 
|  | 225 | + | 
| 208 | 226 | # Use "xargs" to parse quoted args. | 
| 209 | 227 | # | 
| 210 | 228 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. | 
|  | 
0 commit comments