From 24c2280246792eeb98d792d7fb26ed71514f0840 Mon Sep 17 00:00:00 2001 From: Yogthos Date: Thu, 2 Jul 2026 15:33:11 -0400 Subject: [PATCH] Route build shell commands through sh on Windows Chez's system/process use cmd.exe on nt; every build command here is written for sh. bld-sh-wrap spills the command to a temp script and runs sh on it (no cmd quoting), identity on other platforms. --- host/chez/build.ss | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/host/chez/build.ss b/host/chez/build.ss index 1ca0847..722ff7c 100644 --- a/host/chez/build.ss +++ b/host/chez/build.ss @@ -23,7 +23,7 @@ ;; --- shell helpers ---------------------------------------------------------- ;; Run a command, return its stdout as one trimmed string ("" on no output). (define (bld-sh-capture cmd) - (let* ((p (process cmd)) (in (car p))) + (let* ((p (process (bld-sh-wrap cmd))) (in (car p))) (let loop ((acc '())) (let ((l (get-line in))) (if (eof-object? l) @@ -37,7 +37,7 @@ (loop (cons l acc))))))) (define (bld-system cmd) - (let ((rc (system cmd))) + (let ((rc (system (bld-sh-wrap cmd)))) (unless (zero? rc) (error 'jolt-build (string-append "command failed (" (number->string rc) "): " cmd))))) @@ -59,6 +59,23 @@ (define bld-osx? (bld-contains? bld-machine "osx")) (define bld-nt? (bld-contains? bld-machine "nt")) +;; Chez's system/process run through cmd.exe on Windows; every build command +;; here is written for sh (MSYS2 provides it). On nt, spill the command to a +;; script and run `sh ` — workspace paths carry no spaces, and the +;; script file sidesteps cmd's quoting entirely. Identity elsewhere. +(define bld-shell-counter 0) +(define (bld-sh-wrap cmd) + (if bld-nt? + (let* ((tmp (or (getenv "TEMP") (getenv "TMP") ".")) + (f (begin (set! bld-shell-counter (+ bld-shell-counter 1)) + (string-append tmp "\\jolt-sh-" + (number->string bld-shell-counter) ".sh")))) + (let ((p (open-output-file f 'replace))) + (put-string p cmd) + (close-port p)) + (string-append "sh " f)) + cmd)) + ;; The Chez executable, for the isolated compile pass (see build-binary step 4). (define bld-chez (let ((p (bld-sh-capture "command -v chez || command -v scheme || command -v petite")))