diff --git a/gash/parser.scm b/gash/parser.scm index 1547bcb..6780c08 100644 --- a/gash/parser.scm +++ b/gash/parser.scm @@ -817,18 +817,15 @@ as escapable." (->command-list (parse port))) #:quoted? quoted?)) -(define* (read-sh #:optional (port #f)) +(define* (read-sh #:optional (port (current-input-port))) "Read a complete Shell command from @var{port} (or the current input port if @var{port} is unspecified)." - (define stop? #f) (define (stop!) (set! stop? #t)) + (parse port #:lex-hook (lambda (lex) (if stop? '*eoi* (lex))) + #:command-hook stop!)) - (let* ((port (or port (current-input-port)))) - (parse port #:lex-hook (lambda (lex) (if stop? '*eoi* (lex))) - #:command-hook stop!))) - -(define* (read-sh-all #:optional (port #f)) +(define* (read-sh-all #:optional (port (current-input-port))) "Read all complete Shell commands from @var{port} (or the current input port if @var{port} is unspecified)." - (->command-list (parse (or port (current-input-port))))) + (->command-list (parse port)))