Skip to content

Instantly share code, notes, and snippets.

@smcv
Created October 26, 2020 16:09
Show Gist options
  • Save smcv/88f59d07057301e539bbf97e0d238d3c to your computer and use it in GitHub Desktop.
Save smcv/88f59d07057301e539bbf97e0d238d3c to your computer and use it in GitHub Desktop.
From 4313d3755a182cf6dc5ca526549ecb5cd140fde5 Mon Sep 17 00:00:00 2001
From: Simon McVittie <[email protected]>
Date: Mon, 26 Oct 2020 13:27:55 +0000
Subject: [PATCH] _v2-entry-point: Check whether launch_args is empty before
use
In newer versions of bash, an empty array counts as having been set,
and can be dereferenced as `"${array[@]}"` without triggering `set -u`.
However, in older versions, empty arrays count as being unset, and the
entry point script fails with `launch_args[@]: unbound variable`.
Resolves: https://github.com/ValveSoftware/steam-runtime/issues/284
Signed-off-by: Simon McVittie <[email protected]>
---
depot/_v2-entry-point | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/depot/_v2-entry-point b/depot/_v2-entry-point
index 1466364..871b2a2 100755
--- a/depot/_v2-entry-point
+++ b/depot/_v2-entry-point
@@ -246,7 +246,7 @@ if [ -n "$is_main" ]; then
fi
launch_args=( \
- "${launch_args[@]}" \
+ ${launch_args[0]+"${launch_args[@]}"} \
--pass-env-matching '*' \
--terminate \
)
@@ -262,7 +262,7 @@ if [ -n "$is_main" ]; then
"$@"
else
launch_args=( \
- "${launch_args[@]}" \
+ ${launch_args[0]+"${launch_args[@]}"} \
--unset-env LD_PRELOAD \
)
fi
@@ -270,7 +270,7 @@ fi
exec "$pressure_vessel/bin/pressure-vessel-launch" \
--directory="$(pwd)" \
--socket="$rendezvous/socket" \
- "${launch_args[@]}" \
+ ${launch_args[0]+"${launch_args[@]}"} \
-- \
"$@"
exit 125
--
2.28.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment