Use proper utilities for temporary file handling

This commit is contained in:
retropikzel 2025-06-29 12:28:20 +03:00
parent 4dfdacf3ac
commit 16b771f4d2
3 changed files with 18 additions and 18 deletions

View file

@ -1399,15 +1399,14 @@
path path
"/usr/local/share/guile/")))) "/usr/local/share/guile/"))))
((mosh) ((mosh)
(with-output-to-file (call-with-temp-file "snow-mosh.scm"
(make-path (cond-expand (windows (get-environment-variable "TMP")) (lambda (tmp-path out preserve)
(else "/tmp")) (with-output-to-file tmp-path
"snowmosh")
(lambda () (lambda ()
(display "(import (scheme base) (scheme write) (mosh config))") (display "(import (scheme base) (scheme write) (mosh config))")
(newline) (newline)
(display "(display (get-config \"library-path\"))"))) (display "(display (get-config \"library-path\"))")))
(list (make-path (process->sexp '(mosh /tmp/snowmosh)) "lib"))) (list (make-path (process->string `(mosh ,tmp-path)) "lib")))))
((larceny) ((larceny)
(list (list
(make-path (make-path

View file

@ -41,15 +41,15 @@
'(kawa -e "(write (features))")))) '(kawa -e "(write (features))"))))
(mosh "mosh" (mosh -v) #f (mosh "mosh" (mosh -v) #f
,(delay ,(delay
(let ((tmpfile (string-append (cond-expand (windows (get-environment-variable "TMP")) (call-with-temp-file "snow-mosh.scm"
(else "/tmp")) (lambda (tmp-path out preserve)
"/snowmosh"))) (with-output-to-file tmp-path
(with-output-to-file
tmpfile
(lambda () (lambda ()
(display "(import (scheme base) (scheme write) (mosh config)) (display (features))"))) (display "(import (scheme base) (scheme write) (mosh config))")
(newline)
(display "(display (features))")))
(process->sexp (process->sexp
`(mosh ,tmpfile))))) `(mosh ,tmp-path))))))
(larceny "larceny" (larceny --version) "v0.98" (larceny "larceny" (larceny --version) "v0.98"
,(delay '())) ,(delay '()))
(sagittarius "sagittarius" #f #f (sagittarius "sagittarius" #f #f

View file

@ -20,6 +20,7 @@
(chibi pathname) (chibi pathname)
(chibi process) (chibi process)
(chibi string) (chibi string)
(chibi temp-file)
(chibi uri)) (chibi uri))
(cond-expand (cond-expand
(chibi (import (chibi io))) (chibi (import (chibi io)))