Use xargs to split --dry-run args properly for RUN_CMD execution

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
Joakim Erdfelt 2023-02-06 15:47:09 -06:00
parent 8c992b9c93
commit 3b61926500
No known key found for this signature in database
GPG Key ID: 2D0E1FB8FE4B68B4
1 changed files with 4 additions and 6 deletions

View File

@ -170,6 +170,7 @@ dumpEnv()
echo "JETTY_START_LOG = $JETTY_START_LOG" echo "JETTY_START_LOG = $JETTY_START_LOG"
echo "JETTY_STATE = $JETTY_STATE" echo "JETTY_STATE = $JETTY_STATE"
echo "JETTY_START_TIMEOUT = $JETTY_START_TIMEOUT" echo "JETTY_START_TIMEOUT = $JETTY_START_TIMEOUT"
echo "JETTY_SYS_PROPS = $JETTY_SYS_PROPS"
echo "RUN_CMD = ${RUN_CMD[*]}" echo "RUN_CMD = ${RUN_CMD[*]}"
} }
@ -414,9 +415,6 @@ TMPDIR="`cygpath -w $TMPDIR`"
;; ;;
esac esac
BASE_JETTY_SYS_PROPS=$(echo -ne "-Djetty.home=$JETTY_HOME" "-Djetty.base=$JETTY_BASE" "-Djava.io.tmpdir=$TMPDIR")
JETTY_SYS_PROPS=(${JETTY_SYS_PROPS[*]} $BASE_JETTY_SYS_PROPS)
##################################################### #####################################################
# This is how the Jetty server will be started # This is how the Jetty server will be started
##################################################### #####################################################
@ -435,7 +433,7 @@ CYGWIN*) JETTY_START="`cygpath -w $JETTY_START`";;
esac esac
RUN_ARGS=$("$JAVA" -jar "$JETTY_START" --dry-run=opts,path,main,args ${JETTY_ARGS[*]} ${JAVA_OPTIONS[*]}) RUN_ARGS=$("$JAVA" -jar "$JETTY_START" --dry-run=opts,path,main,args ${JETTY_ARGS[*]} ${JAVA_OPTIONS[*]})
RUN_CMD=("$JAVA" $JETTY_SYS_PROPS ${RUN_ARGS[@]}) RUN_CMD=($JETTY_SYS_PROPS ${RUN_ARGS[@]})
##################################################### #####################################################
# Comment these out after you're happy with what # Comment these out after you're happy with what
@ -495,11 +493,11 @@ case "$ACTION" in
# FIXME: Broken solution: wordsplitting, pathname expansion, arbitrary command execution, etc. # FIXME: Broken solution: wordsplitting, pathname expansion, arbitrary command execution, etc.
su - "$JETTY_USER" $SU_SHELL -c " su - "$JETTY_USER" $SU_SHELL -c "
cd \"$JETTY_BASE\" cd \"$JETTY_BASE\"
exec ${RUN_CMD[*]} start-log-file=\"$JETTY_START_LOG\" > /dev/null & echo ${RUN_CMD[*]} start-log-file=\"$JETTY_START_LOG\" | xargs ${JAVA} > /dev/null &
disown \$! disown \$!
echo \$! > \"$JETTY_PID\"" echo \$! > \"$JETTY_PID\""
else else
"${RUN_CMD[@]}" > /dev/null & echo ${RUN_CMD[*]} | xargs ${JAVA} > /dev/null &
disown $! disown $!
echo $! > "$JETTY_PID" echo $! > "$JETTY_PID"
fi fi