From 04578d089deaa31c4d651a8f7b1810c1386f16e3 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Wed, 20 Nov 2024 12:49:50 +0000
Subject: [PATCH] launch-options.sh: Use launch-options.py --command-line-fd

steamrt/tasks#602

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 bin/launch-options.sh | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/bin/launch-options.sh b/bin/launch-options.sh
index df64d864b..7af90d66b 100755
--- a/bin/launch-options.sh
+++ b/bin/launch-options.sh
@@ -28,6 +28,10 @@
 set -e
 set -u
 
+log () {
+    echo "${me-steam-runtime-launch-options}[$$]: $*" >&2 || :
+}
+
 main () {
     me="$(readlink -f "$0")"
     here="${me%/*}"
@@ -95,7 +99,7 @@ main () {
     fi
 
     if ! result="$("$script" --check-gui-dependencies 2>&1)"; then
-        echo "$result" >&2
+        log "error: $result"
 
         if [ -x ~/.steam/root/steam-dialog ]; then
             if [ -e "$script" ]; then
@@ -139,7 +143,14 @@ $result"
         exit 125
     fi
 
-    exec "$script" "$@" || exit 125
+    if command_line="$(exec "$script" --command-line-fd=1 "$@")" && [ -n "$command_line" ]; then
+        log "info: exec $command_line"
+        eval "exec $command_line" || exit 125
+    else
+        log "error: $script failed or was cancelled" >&2
+    fi
+
+    exit 125
 }
 
 main "$@"
-- 
GitLab