From 695751e81ce31798d5bd70b1bb98e9280dc51ce2 Mon Sep 17 00:00:00 2001 From: Eamonn Rea Date: Sat, 23 Mar 2024 01:45:25 +0000 Subject: [PATCH 1/3] extProtonRun: Use 'printf "%q"' when parsing RUNPROGARGS May help with paths that use backslashes. --- steamtinkerlaunch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/steamtinkerlaunch b/steamtinkerlaunch index 0006b8d2..84dbcd7a 100755 --- a/steamtinkerlaunch +++ b/steamtinkerlaunch @@ -7,7 +7,7 @@ PREFIX="/usr" PROGNAME="SteamTinkerLaunch" NICEPROGNAME="Steam Tinker Launch" -PROGVERS="v14.0.20240323-1" +PROGVERS="v14.0.20240323-1 (extProtonRun-printf-q)" PROGCMD="${0##*/}" PROGINTERNALPROTNAME="Proton-stl" SHOSTL="stl" @@ -7079,7 +7079,7 @@ function extProtonRun { if [ -z "$PROGARGS" ] || [ "$PROGARGS" == "$NON" ]; then RUNPROGARGS="" else - mapfile -d " " -t -O "${#RUNPROGARGS[@]}" RUNPROGARGS < <(printf '%s' "$PROGARGS") + mapfile -d " " -t -O "${#RUNPROGARGS[@]}" RUNPROGARGS < <(printf '%q' "$PROGARGS") fi FWAIT=2 From 1a477b92f6957a29b988cd0c6156d34c0f88d399 Mon Sep 17 00:00:00 2001 From: Eamonn Rea Date: Sat, 23 Mar 2024 05:14:35 +0000 Subject: [PATCH 2/3] extProtonRun: Handle custom command arguments with spaces --- steamtinkerlaunch | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/steamtinkerlaunch b/steamtinkerlaunch index 84dbcd7a..29c5d709 100755 --- a/steamtinkerlaunch +++ b/steamtinkerlaunch @@ -7,7 +7,7 @@ PREFIX="/usr" PROGNAME="SteamTinkerLaunch" NICEPROGNAME="Steam Tinker Launch" -PROGVERS="v14.0.20240323-1 (extProtonRun-printf-q)" +PROGVERS="v14.0.20240323-2 (extProtonRun-printf-q)" PROGCMD="${0##*/}" PROGINTERNALPROTNAME="Proton-stl" SHOSTL="stl" @@ -7079,12 +7079,37 @@ function extProtonRun { if [ -z "$PROGARGS" ] || [ "$PROGARGS" == "$NON" ]; then RUNPROGARGS="" else - mapfile -d " " -t -O "${#RUNPROGARGS[@]}" RUNPROGARGS < <(printf '%q' "$PROGARGS") + mapfile -d " " -t -O "${#TMP_RUNPROGARGS[@]}" TMP_RUNPROGARGS < <( printf "%q" "$PROGARGS" ) + + # Basically check for and join paths that contain spaces because above mapfile will strip them + # TODO: This does NOT work with paths that use forward slashes + for i in "${!TMP_RUNPROGARGS[@]}"; do + # Remove trailing backslash, i.e. turn `--launch\` into `--launch` + TMP_RUNPROGARGS[i]="${TMP_RUNPROGARGS[i]%\\}" + + # If the last seen element in the array ended with a backslash, assume + # this is an incomplete path and join them + # + # This is not perfect as valid paths that just end with backslashes will not work, + # but we can document this on the wiki + # + # i.e. "Z:\this\is\a\path\ MY_VAR=2" will not work, but "Z:\this\is\a\path MY_VAR=2" will work + if [[ $LASTRUNPROGARG = *"\\" ]]; then + # Remove 'i-1' (previous element), because 'i' (current element) will contain 'i-1' + unset "TMP_RUNPROGARGS[i-1]" + TMP_RUNPROGARGS[i]="${LASTRUNPROGARG} ${TMP_RUNPROGARGS[i]}" + fi + LASTRUNPROGARG="${TMP_RUNPROGARGS[i]}" + done + + # Generate new array with null strings removed. + mapfile -t -O "${#RUNPROGARGS[@]}" RUNPROGARGS < <( printf "%s\n" "${TMP_RUNPROGARGS[@]}" | grep -v "^$" ) fi FWAIT=2 # mirrors above RUNPROGARGS + # TODO what if we try to pass paths with spaces? This could be problematic here... if [ -z "$EXTPROGRAMARGS" ]; then writelog "INFO" "${FUNCNAME[0]} - No external program args here it seems" RUNEXTPROGRAMARGS=( "" ) From 775187803ddc8c6cd372390c582e2014590dff1e Mon Sep 17 00:00:00 2001 From: Eamonn Rea Date: Sun, 24 Mar 2024 21:27:30 +0000 Subject: [PATCH 3/3] version bump --- steamtinkerlaunch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/steamtinkerlaunch b/steamtinkerlaunch index 29c5d709..5f72b0f5 100755 --- a/steamtinkerlaunch +++ b/steamtinkerlaunch @@ -7,7 +7,7 @@ PREFIX="/usr" PROGNAME="SteamTinkerLaunch" NICEPROGNAME="Steam Tinker Launch" -PROGVERS="v14.0.20240323-2 (extProtonRun-printf-q)" +PROGVERS="v14.0.20240325-1" PROGCMD="${0##*/}" PROGINTERNALPROTNAME="Proton-stl" SHOSTL="stl"