Skip to content

Run Windows games on Apple Silicon — free, open source, with an open compatibility database that tells you what actually works.

cli: `run` exits with the status Wine reports for the program, so scripts can check $? instead of grepping exit=

Ian Helfrich646645625871
diff --git a/.claude/skills/investigate-issue/reference.md b/.claude/skills/investigate-issue/reference.md
index 336e7ed..1ffa8e6 100644
--- a/.claude/skills/investigate-issue/reference.md
+++ b/.claude/skills/investigate-issue/reference.md
@@ -25,7 +25,10 @@ swift build && swift test # from the repo root
.build/debug/highball bottle kill <bottle> # stop the wineserver before poking a prefix
```
-`highball run` always exits 0. Assert on its output, never on `$?`.
+`highball run` exits with the status Wine reports for the program, the low 8 bits of the Windows
+code (3010 arrives as 194), after printing `exit=N` and the log path. A CLI error such as a missing
+bottle also exits nonzero, so read the output to tell the two apart. `Scripts/test-cli-exit.sh
+.build/debug/highball <disposable bottle>` checks this contract.
## Smoke tests
diff --git a/Scripts/e2e-install.sh b/Scripts/e2e-install.sh
index 58b8c10..e65d2d1 100755
--- a/Scripts/e2e-install.sh
+++ b/Scripts/e2e-install.sh
@@ -104,8 +104,9 @@ fi
"$HB" recipe apply e2e "$DB/recipes/tweaks/vcrun2022.json"
test -f "$B/drive_c/windows/system32/vcruntime140.dll" || { echo "vcruntime140 (x64) missing"; exit 1; }
test -f "$B/drive_c/windows/syswow64/vcruntime140.dll" || { echo "vcruntime140 (x86) missing"; exit 1; }
-# NOTE: 'highball run' always exits 0 — assert on its output, never on $?.
-out=$("$HB" run e2e reg --verbose -- query 'HKLM\SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\X64' /v Installed)
+# NOTE: 'highball run' exits with the status Wine reports for the program, and reg query exits 1
+# when the key is missing. `|| true` keeps set -e from aborting before the checks below print its output.
+out=$("$HB" run e2e reg --verbose -- query 'HKLM\SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\X64' /v Installed) || true
echo "$out" | grep -qE 'Installed[[:space:]]+REG_DWORD[[:space:]]+0x1' || { echo "VC++ x64 marker missing:"; echo "$out"; exit 1; }
echo "$out" | grep -q 'exit=0' || { echo "reg query wine process failed:"; echo "$out"; exit 1; }
echo "vcrun2022 ok"
@@ -114,7 +115,7 @@ if [ "$WITH_DOTNET" -eq 1 ]; then
step "dotnet48 recipe (winetricks through bash — the #16 chain; 5-40 min depending on cache)"
"$HB" recipe apply e2e "$DB/recipes/tweaks/dotnet48.json"
# 0x80eb1 = 528049 = .NET Framework 4.8's release id (update if the recipe ever targets a newer 4.x).
- out=$("$HB" run e2e reg --verbose -- query 'HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full' /v Release)
+ out=$("$HB" run e2e reg --verbose -- query 'HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full' /v Release) || true
echo "$out" | grep -qi '0x80eb1' || { echo ".NET 4.8 marker (528049) missing:"; echo "$out"; exit 1; }
echo "dotnet48 ok"
fi
diff --git a/Scripts/render-smoke.sh b/Scripts/render-smoke.sh
index a0bff4d..019b933 100755
--- a/Scripts/render-smoke.sh
+++ b/Scripts/render-smoke.sh
@@ -31,7 +31,7 @@ fi
"$HB" bottle delete "$BOTTLE" 2>/dev/null || true
"$HB" bottle create "$BOTTLE" ${ENGINE:+--engine "$ENGINE"}
-"$HB" run "$BOTTLE" "$DL" -- /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-
+"$HB" run "$BOTTLE" "$DL" -- /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- || echo "Heaven installer exited $?; checking for Heaven.exe"
EXE="$HOME/Library/Application Support/Highball/bottles/$BOTTLE/drive_c/Program Files (x86)/Unigine/Heaven Benchmark 4.0/bin/Heaven.exe"
test -f "$EXE" || { echo "Heaven install failed"; exit 1; }
ARGS_COMMON=(-project_name Heaven -data_path ../ -engine_config ../data/heaven_4.0.cfg
diff --git a/Scripts/test-cli-exit.sh b/Scripts/test-cli-exit.sh
new file mode 100755
index 0000000..1486488
--- /dev/null
+++ b/Scripts/test-cli-exit.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+# Integration regression: requires an existing disposable/test Wine bottle.
+# Runs only cmd.exe; does not install or launch Steam or a game.
+set -euo pipefail
+
+if [[ $# -ne 2 ]]; then
+ printf 'Usage: %s <highball-cli> <bottle>\n' "$0" >&2
+ exit 2
+fi
+
+cli=$1
+bottle=$2
+
+for expected in 0 7; do
+ actual=0
+ output=$(timeout 60 "$cli" run "$bottle" cmd -- /c exit "$expected" 2>&1) || actual=$?
+ if [[ $actual -ne $expected ]]; then
+ printf 'FAIL: Windows exit %s returned shell status %s\n%s\n' "$expected" "$actual" "$output" >&2
+ exit 1
+ fi
+ printf 'PASS: Windows exit %s returned shell status %s\n' "$expected" "$actual"
+done
diff --git a/Sources/highball/main.swift b/Sources/highball/main.swift
index 077fb53..f9755e3 100644
--- a/Sources/highball/main.swift
+++ b/Sources/highball/main.swift
@@ -367,6 +367,10 @@ struct Run: AsyncParsableCommand {
print("hint: exited within 10 s; try another renderer (--renderer dxmt|d3dmetal|dxvk|wined3d)")
}
}
+ // The status Wine reports for the program becomes the CLI's, so scripts can assert on $?
+ // (Scripts/test-cli-exit.sh) instead of grepping the exit= line. Wine keeps the low 8 bits
+ // of the Windows code: 0 only for 0, but 3010 arrives as 194 and 256 as 1.
+ throw ExitCode(result.exitStatus)
}
}