Skip to content

Commit

Permalink
Shellcheck fixes for api gradlew
Browse files Browse the repository at this point in the history
Signed-off-by: Judy Ng <[email protected]>
  • Loading branch information
judysng committed Jan 3, 2024
1 parent 1830acb commit ec4efe1
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions api/gradlew
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
#!/usr/bin/env bash

#
# Copyright 2015 the original author or authors.
Expand Down Expand Up @@ -36,9 +36,9 @@ while [ -h "$PRG" ] ; do
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
cd "`dirname \"$PRG\"`/" >/dev/null || exit
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
cd "$SAVED" >/dev/null || exit

APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
Expand Down Expand Up @@ -106,10 +106,10 @@ location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ "$cygwin" = "false" ] && [ "$darwin" = "false" ] && [ "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=$(ulimit -H -n)
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
if [ "$MAX_FD" = "maximum" ] || [ "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
Expand All @@ -127,14 +127,14 @@ if $darwin; then
fi

# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
if [ "$cygwin" = "true" ] || [ "$msys" = "true" ] ; then
APP_HOME=$(cygpath --path --mixed "$APP_HOME")
CLASSPATH=$(cygpath --path --mixed "$CLASSPATH")

JAVACMD=`cygpath --unix "$JAVACMD"`
JAVACMD=$(cygpath --unix "$JAVACMD")

# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
ROOTDIRSRAW=$(find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null)
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
Expand All @@ -148,16 +148,17 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
CHECK=$(echo "$arg"|egrep -c "$OURCYGPATTERN" -)
CHECK2=$(echo "$arg"|egrep -c "^-") ### Determine if an option

if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
eval args$i="$(cygpath --path --ignore --mixed "$arg")"
else
eval `echo args$i`="\"$arg\""
eval args$i="\"$arg\""
fi
i=`expr $i + 1`
i=$((i+1))
done
# shellcheck disable=SC2154 # Shellcheck doesn't check for dynamic assignments
case $i in
0) set -- ;;
1) set -- "$args0" ;;
Expand Down

0 comments on commit ec4efe1

Please sign in to comment.