Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit
Swift apple-silicond3dmetaldxmtdxvkgame-porting-toolkitgptkmac-gamingmacosmetalfxrosetta-2steamsteam-playwinewinecx
fix(launch): pass alert text to osascript as arguments (#2066)
Raymond Chin1c920df44318
diff --git a/app/Tests/BridgeplayAppTests/PrefixToolsTests.swift b/app/Tests/BridgeplayAppTests/PrefixToolsTests.swiftindex 8c230aa..cb1623b 100644--- a/app/Tests/BridgeplayAppTests/PrefixToolsTests.swift+++ b/app/Tests/BridgeplayAppTests/PrefixToolsTests.swift@@ -390,14 +390,16 @@ struct PrefixToolsTests {#expect(built.lowerBound < installed.lowerBound)}- // A newline inside an AppleScript string literal is a syntax error, so osascript writes- // nothing and the launch still stops, with no dialog ever reaching the screen to say why.- @Test("The alert reaches osascript as one line")- func alertIsOneLine() throws {+ // Text inside an AppleScript string literal can break it, so osascript writes nothing and+ // the launch still stops, with no dialog ever reaching the screen to say why.+ @Test("The alert text reaches osascript as arguments")+ func alertTextIsArguments() throws {let source = try Self.compatSource()- let opening = try #require(source.range(of: "display alert"))- let closing = try #require(source.range(of: #"" as critical"#))- #expect(!source[opening.lowerBound..<closing.lowerBound].contains("\n"))+ let helper = try #require(source.range(of: "show_alert() {\n"))+ let script = try #require(source.range(of: #"osascript - "$1" "$2" >/dev/null 2>&1 <<'APPLESCRIPT' || true"#))+ let alert = try #require(source.range(of: "display alert (item 1 of argv) message (item 2 of argv) as critical"))+ #expect(helper.upperBound < script.lowerBound)+ #expect(script.upperBound < alert.lowerBound)}// Steam runs the tool twice for one launch and both passes reach the refusal, so andiff --git a/dylib/feats/compat_run.sh b/dylib/feats/compat_run.shindex 80d4e2c..5e60550 100755--- a/dylib/feats/compat_run.sh+++ b/dylib/feats/compat_run.sh@@ -1010,8 +1010,10 @@ show_alert() {[ "$verb" != run ] || return 0launch_step dialogexec 8>&- 9>&-- osascript >/dev/null 2>&1 <<APPLESCRIPT || true-display alert "$1" message "$2" as critical+ osascript - "$1" "$2" >/dev/null 2>&1 <<'APPLESCRIPT' || true+on run argv+ display alert (item 1 of argv) message (item 2 of argv) as critical+end runAPPLESCRIPT}diff --git a/dylib/tests/buildcheck.sh b/dylib/tests/buildcheck.shindex df39ade..2e2c7a3 100644--- a/dylib/tests/buildcheck.sh+++ b/dylib/tests/buildcheck.sh@@ -110,13 +110,17 @@ data=$(mktemp -d "$work/compatdata.XXXXXX")elseecho held > "$data/during-alert"fi+ shift+ printf '%s\n' "$@" > "$data/alert-args"}eval "$alert"exec 8>> "$data/.notproton-prefix.lock"/usr/bin/lockf -s -t 0 8- show_alert "title" "message"+ show_alert "title" 'a "quoted" \ message')is "an open alert does not keep the prefix locked" "free" "$(cat "$data/during-alert" 2>/dev/null)"+is "alert text reaches osascript untouched, as arguments" 'title+a "quoted" \ message' "$(cat "$data/alert-args" 2>/dev/null)"echo "== rebuild choices =="arch_functions="$(extract prefix_machine)