/usr/lib/s9fes/standard-error.scm is in scheme9 2010.11.13-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | ; Scheme 9 from Empty Space, Function Library
; By Nils M Holm, 2010
; See the LICENSE file of the S9fES package for terms of use
;
; (standard-error) ==> #<output-port>
; (call-with-stderr procedure^1) ==> object
; (with-output-to-stderr procedure^0) ==> unspecific
;
; (load-from-library "standard-error.scm")
;
; STANDARD-ERROR returns an output-file for accessing the Unix
; standard error file descriptor (stderr). CALL-WITH-STDERR passes
; that output-file to a unary procedure, which may use it for writing
; data to stderr. WITH-OUTPUT-TO-STDERR temporarily sets the current
; output port) to the stderr descriptor while running the given nullary
; procedure. CALL-WITH-STDERR returns the value returned by PROCEDURE^1.
;
; (Example): (call-with-stderr
; (lambda (stderr)
; (display "Something went wrong!" stderr)
; (newline stderr))) ==> unspecific
(require-extension sys-unix)
(define standard-error-port
(let ((stderr #f))
(lambda ()
(if (not stderr)
(set! stderr (sys:make-output-port 2)))
stderr)))
(define call-with-stderr
(let ((standard-error-port standard-error-port))
(lambda (proc1)
(let ((r (proc1 (standard-error-port))))
(sys:flush (standard-error-port))
r))))
(define with-output-to-stderr
(let ((set-output-port! set-output-port!)
(standard-error-port standard-error-port))
(lambda (thunk)
(let ((outer-port (current-output-port)))
(set-output-port! (standard-error-port))
(thunk)
(sys:flush (standard-error-port))
(set-output-port! outer-port)))))
|