What about this patch? Is there a way to compose the following part somehow to prevent a possible race condition? (rename-file prog prog-real) (with-output-to-file prog (lambda () (format #t "#!~a~%~a~%exec ~a~%" (which "bash") (string-join (map export-variable vars) "\n") (canonicalize-path prog-real)))) (chmod prog #o755)))