parser: Simplify default port handling.
* gash/parser.scm (read-sh, read-sh-all): Set the default value for the 'port' argument in the usual way (rather than doing it manually).
This commit is contained in:
parent
57d21182e2
commit
eae0953f31
|
@ -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)))
|
||||
|
|
Loading…
Reference in New Issue