gitlab-ci: fix quoting of variables passed down to bare-metal runners
authorEric Engestrom <eric@engestrom.ch>
Tue, 18 Aug 2020 22:47:16 +0000 (00:47 +0200)
committerMarge Bot <eric+marge@anholt.net>
Wed, 19 Aug 2020 21:53:31 +0000 (21:53 +0000)
Eric Anholt identified the issue when merging one of my MRs: the
variable contained words in '`' backticks, which caused them to be
executed by the bare metal runner's shell.

Quote the value printed using bash's shell expansion feature to make
sure anything in the future will be properly quoted.

Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6389>

.gitlab-ci/bare-metal/rootfs-setup.sh

index 220968aa05778db2da1055134132ca7d74037bad..27a5c40de2e568cf4cc9152a90bc77c3d504db85 100644 (file)
@@ -49,9 +49,8 @@ for var in \
     TU_DEBUG \
     VK_DRIVER \
     ; do
     TU_DEBUG \
     VK_DRIVER \
     ; do
-  val=`echo ${!var} | sed 's|"||g'`
   if [ -n "${!var+x}" ]; then
   if [ -n "${!var+x}" ]; then
-    echo "export $var=\"${val}\"" >> $rootfs_dst/set-job-env-vars.sh
+    echo "export $var=${!var@Q}" >> $rootfs_dst/set-job-env-vars.sh
   fi
 done
 echo "Variables passed through:"
   fi
 done
 echo "Variables passed through:"