support for copying the temporary file from an existing file

This commit is contained in:
2025-09-09 16:04:58 -07:00
parent 289e95280c
commit 5fdf026536

View File

@@ -8,13 +8,15 @@
(or/c char-numeric? char-alphabetic? (curry char=? #\-)) (or/c char-numeric? char-alphabetic? (curry char=? #\-))
(string->list call)))) (string->list call))))
(define (our-make-temporary-file) (define (our-make-temporary-file [copy-from #f])
;; when deployed as a systemd socket, this program is expected to be ;; when deployed as a systemd socket, this program is expected to be
;; ran with PrivateTmp. however, in case this is not true, we still ;; ran with PrivateTmp. however, in case this is not true, we still
;; make our own directory. "red", the restricted version of "ed", ;; make our own directory. "red", the restricted version of "ed",
;; has no facility for getting outside of the directory we start it ;; has no facility for getting outside of the directory we start it
;; in. ;; in.
(make-temporary-file "red.~a" #:base-dir (make-temporary-directory))) (make-temporary-file "red.~a"
#:copy-from copy-from
#:base-dir (make-temporary-directory)))
;; unfortunately, we cannot just exec red and let it take over the ;; unfortunately, we cannot just exec red and let it take over the
;; I/O. ed, being the standard text editor, only works with standard ;; I/O. ed, being the standard text editor, only works with standard