-
-
Save codemac/7cd2625341ea34bd9a22a0146a270119 to your computer and use it in GitHub Desktop.
guile test stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; note: source file /home/jmickey/tmp/./test.scm | |
;;; newer than compiled /home/jmickey/.cache/guile/ccache/2.0-LE-8-2.0/home/jmickey/tmp/test.scm.go | |
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0 | |
;;; or pass the --no-auto-compile argument to disable. | |
;;; compiling /home/jmickey/tmp/./test.scm | |
;;; compiled /home/jmickey/.cache/guile/ccache/2.0-LE-8-2.0/home/jmickey/tmp/test.scm.go | |
what was stored in stdout: | |
<eond of os> | |
what was stored in stderr: | |
<eond of es> | |
what was stored in stdout: | |
help me i'm stdout | |
<eond of os> | |
what was stored in stderr: | |
<eond of es> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (ice-9 popen)) | |
(define (port-copy dst src) | |
(let ((c (read-char src))) | |
(if (eof-object? c) | |
dst | |
(begin (write-char c dst) | |
(port-copy dst src))))) | |
(define (print-outs one two) | |
(format #t "what was stored in stdout:~%~a~%<eond of os>~%" (get-output-string os)) | |
(format #t "what was stored in stderr:~%~a~%<eond of es>~%" (get-output-string es))) | |
(let ((os (open-output-string)) | |
(es (open-output-string))) | |
(parameterize ((current-error-port es)) | |
(let ((rp (open-pipe* OPEN_BOTH; "dd" "if=/dev/zero" "of=/dev/zero" "bs=1" "count=20" | |
"logger" "-s" "help me i'm stderr"))) | |
(port-copy os rp) | |
(status:exit-val (close-pipe rp)))) | |
(print-outs os es)) | |
(let ((os (open-output-string)) | |
(es (open-output-string))) | |
(parameterize ((current-error-port es)) | |
(let ((rp (open-pipe* OPEN_BOTH; "dd" "if=/dev/zero" "of=/dev/zero" "bs=1" "count=20" | |
"echo" "help me i'm stdout"))) | |
(port-copy os rp) | |
(status:exit-val (close-pipe rp)))) | |
(print-outs os es)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=24680