Skip to content

Commit 7bf721b

Browse files
committed
Switch to Bash arrays in q2 script to preserve quoted arguments
1 parent e0564ca commit 7bf721b

File tree

1 file changed

+8
-9
lines changed
  • jpos/src/dist/bin

1 file changed

+8
-9
lines changed

jpos/src/dist/bin/q2

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
cd "$(dirname "$0")/.." || exit 1
44
rm -f deploy/shutdown.xml
55

6-
# Separate -D parameters and handle --pid argument
7-
JAVA_OPTS="${JAVA_OPTS:-}"
8-
OTHER_OPTS=""
6+
# Initialize arrays for JAVA_OPTS and OTHER_OPTS.
7+
JAVA_OPTS=()
8+
OTHER_OPTS=()
99
PID_FILE="jpos.pid" # Default value
1010

1111
for arg in "$@"; do
1212
case $arg in
1313
-D*)
14-
JAVA_OPTS="$JAVA_OPTS $arg"
14+
JAVA_OPTS+=("$arg")
1515
;;
1616
--pid=*)
1717
PID_FILE="${arg#--pid=}"
1818
;;
1919
*)
20-
OTHER_OPTS="$OTHER_OPTS $arg"
20+
OTHER_OPTS+=("$arg")
2121
;;
2222
esac
2323
done
2424

2525
# Check if the process defined by the PID file is running
26-
if [ -f "$PID_FILE" ] && ps -p "$(cat "$PID_FILE")" > /dev/null 2>&1
27-
then
26+
if [ -f "$PID_FILE" ] && ps -p "$(cat "$PID_FILE")" > /dev/null 2>&1; then
2827
echo "Process $(cat "$PID_FILE") is running"
2928
else
3029
rm -f "$PID_FILE"
@@ -34,5 +33,5 @@ else
3433
-Xmx4G \
3534
--enable-preview \
3635
-Xlog:gc:log/gc.log \
37-
$JAVA_OPTS -jar @jarname@ --pid="$PID_FILE" $OTHER_OPTS
36+
"${JAVA_OPTS[@]}" -jar @jarname@ --pid="$PID_FILE" "${OTHER_OPTS[@]}"
3837
fi

0 commit comments

Comments
 (0)