Closed Micke90s closed 1 year ago
Short description to the behaviour of the parameters.
When the parameters are displayed using echo
we get
-batchmode -logfile CoreKeeperServerLog.txt -world 0 -worldname Core Keeper Server -worldseed 0 -worldmode 0 -gameid ABCDEFGHIJKLMNPQRSTUVWXZABCD -datapath /home/steam/core_keeper_data/savegames -maxplayers 10 -season 3
In this case the spaces within the values are confusing. (That's why I escaped the values in the merge request #21 )
I created a test script to check if the parameters are used correctly.
test1.sh:
#!/bin/bash
#Build Parameters
declare -a params
params=(-batchmode -logfile "CoreKeeperServerLog.txt")
if [ ! -z "${WORLD_INDEX}" ]; then params=( "${params[@]}" -world "${WORLD_INDEX}" ); fi
if [ ! -z "${WORLD_NAME}" ]; then params=( "${params[@]}" -worldname "${WORLD_NAME}" ); fi
if [ ! -z "${WORLD_SEED}" ]; then params=( "${params[@]}" -worldseed "${WORLD_SEED}" ); fi
if [ ! -z "${WORLD_MODE}" ]; then params=( "${params[@]}" -worldmode "${WORLD_MODE}" ); fi
if [ ! -z "${GAME_ID}" ]; then params=( "${params[@]}" -gameid "${GAME_ID}" ); fi
if [ ! -z "${DATA_PATH}" ]; then params=( "${params[@]}" -datapath "${DATA_PATH}" ); fi
if [ ! -z "${MAX_PLAYERS}" ]; then params=( "${params[@]}" -maxplayers "${MAX_PLAYERS}" ); fi
if [ ! -z "${SEASON}" ]; then params=( "${params[@]}" -season "${SEASON}" ); fi
if [ ! -z "${SERVER_IP}" ]; then params=( "${params[@]}" -ip "${SERVER_IP}" ); fi
if [ ! -z "${SERVER_PORT}" ]; then params=( "${params[@]}" -port "${SERVER_PORT}" ); fi
./test2.sh "${params[@]}"
test2.sh
#!/bin/bash
for n in $(seq 1 $#); do
echo $1
shift
done
Result:
-batchmode
-logfile
CoreKeeperServerLog.txt
-world
0
-worldname
Core Keeper Server
-worldseed
0
-worldmode
0
-gameid
ABCDEFGHIJKLMNPQRSTUVWXZABCD
-datapath
/home/steam/core_keeper_data/savegames
-maxplayers
10
-season
3
Now everything seems to work as suspected.
Some parameters were double encoded.
Sorry for the inconvenience.