Preserve input and error ports in substitutions

This was simply a mistake.

* geesh/shell.scm (sh:substitute-command): Leave 'current-input-port'
and 'current-error-port' alone.
* tests/shell.scm: Remove tests that check that input and error gets
ignored during substitutions.
This commit is contained in:
Timothy Sample 2018-11-15 13:40:58 -05:00
parent 085c35a833
commit 0ae52599c4
2 changed files with 1 additions and 47 deletions

View File

@ -211,12 +211,7 @@ a string."
(match-let* (((sink . source) (pipe))
(thunk* (lambda ()
(close-port sink)
(let ((in (open-file "/dev/null" "r"))
(err (open-file "/dev/null" "w")))
(parameterize ((current-input-port in)
(current-output-port source)
(current-error-port err))
(thunk)))))
(with-output-to-port source thunk)))
(pid (%subshell thunk*)))
(close-port source)
(match-let ((result (string-trim-right (get-string-all sink) #\newline))

View File

@ -366,21 +366,6 @@
(lambda ()
(display "foo")))))
(test-equal "Substitutions ignore standard error for built-ins"
"foo"
(let ((env (make-environment '())))
(sh:substitute-command env
(lambda ()
(display "foo")
(display "bar" (current-error-port))))))
(test-equal "Substitutions have null standard input for built-ins"
""
(let ((env (make-environment '())))
(sh:substitute-command env
(lambda ()
(display (get-string-all (current-input-port)))))))
(test-equal "Substitutes output from external utilities"
"foo"
(call-with-temporary-directory
@ -393,32 +378,6 @@
(lambda ()
(sh:exec env utility)))))))
(test-equal "Substitutions ignore standard error for external utilities"
"foo"
(call-with-temporary-directory
(lambda (directory)
(let ((utility (string-append directory "/utility"))
(env (make-environment '())))
(make-script utility
(display "foo")
(display "bar" (current-error-port)))
(sh:substitute-command env
(lambda ()
(sh:exec env utility)))))))
(test-equal "Substitutions have null standard input for external utilities"
""
(call-with-temporary-directory
(lambda (directory)
(let ((utility (string-append directory "/utility"))
(env (make-environment '())))
(make-script utility
(use-modules (ice-9 textual-ports))
(display (get-string-all (current-input-port))))
(sh:substitute-command env
(lambda ()
(sh:exec env utility)))))))
(test-equal "Trailing newlines are trimmed from substitutions"
"foo"
(let ((env (make-environment '())))