From fdeffca32a080d5ee0237c224685348f6b461701 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Fri, 6 Sep 2024 21:18:59 +0300
Subject: [PATCH 16/16] meson-installer_build.sh: Improve env var quotation

See RM #828

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 .../installer_cross/meson-installer_build.sh  | 64 +++++++++----------
 1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/platforms/windows/installer_cross/meson-installer_build.sh b/platforms/windows/installer_cross/meson-installer_build.sh
index c34201c72f..47ca7f5e98 100755
--- a/platforms/windows/installer_cross/meson-installer_build.sh
+++ b/platforms/windows/installer_cross/meson-installer_build.sh
@@ -120,7 +120,7 @@ fi
 DLLSPATH="$1"
 GUI="$2"
 
-case "$GUI" in
+case "${GUI}" in
   gtk3.22)
     GUINAME="GTK3.22"
     MPGUI="gtk3"
@@ -149,24 +149,24 @@ case "$GUI" in
   ruledit)
     ;;
   *)
-    echo "Unknown gui type \"$GUI\"" >&2
+    echo "Unknown gui type \"${GUI}\"" >&2
     exit 1 ;;
 esac
 
-if test "$CLIENT" = "" ; then
-  CLIENT="$GUI"
+if test "${CLIENT}" = "" ; then
+  CLIENT="${GUI}"
 fi
 
-if ! test -d "$DLLSPATH" ; then
-  echo "Dllstack directory \"$DLLSPATH\" not found!" >&2
+if ! test -d "${DLLSPATH}" ; then
+  echo "Dllstack directory \"${DLLSPATH}\" not found!" >&2
   exit 1
 fi
 
-if ! ./meson-winbuild.sh "$DLLSPATH" "$GUI" ; then
+if ! ./meson-winbuild.sh "${DLLSPATH}" "${GUI}" ; then
   exit 1
 fi
 
-SETUP=$(grep "CrosserSetup=" $DLLSPATH/crosser.txt | sed -e 's/CrosserSetup="//' -e 's/"//')
+SETUP=$(grep "CrosserSetup=" "${DLLSPATH}/crosser.txt" | sed -e 's/CrosserSetup="//' -e 's/"//')
 
 SRC_ROOT="$(cd ../../.. || exit 1 ; pwd)"
 
@@ -177,7 +177,7 @@ if ! ( cd "meson/build/${SETUP}-${GUI}" && ninja langstat_core.txt ) ; then
   exit 1
 fi
 
-if test "$GUI" = "ruledit" &&
+if test "${GUI}" = "ruledit" &&
    ! ( cd "meson/build/${SETUP}-${GUI}" && ninja langstat_ruledit.txt ) ; then
   echo "langstat_ruledit.txt creation failed!" >&2
   exit 1
@@ -191,32 +191,32 @@ fi
 
 INSTDIR="meson/install/freeciv-${VERREV}-${SETUP}-${GUI}"
 
-if ! mv $INSTDIR/bin/* $INSTDIR/ ||
-   ! mv $INSTDIR/share/freeciv $INSTDIR/data ||
-   ! mv $INSTDIR/share/doc $INSTDIR/ ||
-   ! mkdir -p $INSTDIR/doc/freeciv/installer ||
+if ! mv "${INSTDIR}/bin/"* "${INSTDIR}/" ||
+   ! mv "${INSTDIR}/share/freeciv" "${INSTDIR}/data" ||
+   ! mv "${INSTDIR}/share/doc" "${INSTDIR}/" ||
+   ! mkdir -p "${INSTDIR}/doc/freeciv/installer" ||
    ! cat licenses/header.txt "${SRC_ROOT}/COPYING" \
      > "${INSTDIR}/doc/freeciv/installer/COPYING.installer" ||
-   ! rm -Rf $INSTDIR/lib ||
-   ! cp Freeciv.url $INSTDIR/
+   ! rm -Rf "${INSTDIR}/lib" ||
+   ! cp Freeciv.url "${INSTDIR}/"
 then
   echo "Rearranging install directory failed!" >&2
   exit 1
 fi
 
-if ! add_common_env "$DLLSPATH" "$INSTDIR" ; then
+if ! add_common_env "${DLLSPATH}" "${INSTDIR}" ; then
   echo "Copying common environment failed!" >&2
   exit 1
 fi
 
 NSI_DIR="meson/nsi"
 
-if ! mkdir -p "$NSI_DIR" ; then
-  echo "Creating \"$NSI_DIR\" directory failed" >&2
+if ! mkdir -p "${NSI_DIR}" ; then
+  echo "Creating \"${NSI_DIR}\" directory failed" >&2
   exit 1
 fi
 
-if test "$GUI" = "ruledit" ; then
+if test "${GUI}" = "ruledit" ; then
   if ! cp freeciv-ruledit.cmd "${INSTDIR}/"
   then
     echo "Adding cmd-file failed!" >&2
@@ -236,37 +236,37 @@ if test "$GUI" = "ruledit" ; then
     exit 1
   fi
 else
-  if ! cp freeciv-server.cmd freeciv-${CLIENT}.cmd freeciv-mp-${FCMP}.cmd $INSTDIR/
+  if ! cp freeciv-server.cmd "freeciv-${CLIENT}.cmd" "freeciv-mp-${FCMP}.cmd" "${INSTDIR}/"
   then
     echo "Adding cmd-files failed!" >&2
     exit 1
   fi
 
-  if ! add_sdl2_mixer_env "$DLLSPATH" "$INSTDIR" ; then
+  if ! add_sdl2_mixer_env "${DLLSPATH}" "${INSTDIR}" ; then
     echo "Copying SDL2_mixer environment failed!" >&2
     exit 1
   fi
 
   case $GUI in
     gtk3.22)
-      if ! add_gtk3_env "$DLLSPATH" "$INSTDIR" ; then
+      if ! add_gtk3_env "${DLLSPATH}" "${INSTDIR}" ; then
         echo "Copying gtk3 environment failed!" >&2
         exit 1
       fi
       ;;
     gtk4|gtk4x)
-      if ! add_gtk4_env "$DLLSPATH" "$INSTDIR" ; then
+      if ! add_gtk4_env "${DLLSPATH}" "${INSTDIR}" ; then
         echo "Copying gtk4 environment failed!" >&2
         exit 1
       fi
       ;;
     sdl2)
       # For gtk4 modpack installer
-      if ! add_gtk4_env "$DLLSPATH" "$INSTDIR" ; then
+      if ! add_gtk4_env "${DLLSPATH}" "${INSTDIR}" ; then
         echo "Copying gtk4 environment failed!" >&2
         exit 1
       fi
-      if ! add_sdl2_env "$DLLSPATH" "$INSTDIR" ; then
+      if ! add_sdl2_env "${DLLSPATH}" "${INSTDIR}" ; then
         echo "Copying sdl2 environment failed!" >&2
         exit 1
       fi
@@ -299,18 +299,18 @@ else
 
   NSI_FILE="${NSI_DIR}/client-${SETUP}-${VERREV}-${GUI}.nsi"
 
-  if test "$GUI" = "sdl2" ; then
+  if test "${GUI}" = "sdl2" ; then
     if ! ./create-freeciv-sdl2-nsi.sh \
-           "$INSTDIR" "meson/output" "$VERREV" "$SETUP" "$UNINSTALLER" \
-             > "$NSI_FILE"
+           "${INSTDIR}" "meson/output" "${VERREV}" "${SETUP}" "${UNINSTALLER}" \
+             > "${NSI_FILE}"
     then
       exit 1
     fi
   else
     if ! ./create-freeciv-gtk-qt-nsi.sh \
-           "$INSTDIR" "meson/output" "$VERREV" "$GUI" "$GUINAME" \
-           "$SETUP" "$MPGUI" "$EXE_ID" "$UNINSTALLER" \
-             > "$NSI_FILE"
+           "${INSTDIR}" "meson/output" "${VERREV}" "${GUI}" "${GUINAME}" \
+           "${SETUP}" "${MPGUI}" "${EXE_ID}" "${UNINSTALLER}" \
+             > "${NSI_FILE}"
     then
       exit 1
     fi
@@ -322,7 +322,7 @@ if ! mkdir -p meson/output ; then
   exit 1
 fi
 
-if ! makensis -NOCD "$NSI_FILE"
+if ! makensis -NOCD "${NSI_FILE}"
 then
   echo "Creating installer failed!" >&2
   exit 1
-- 
2.45.2

