builtins: Oops, have \NAME run builtin.

* gash/script.scm (command): Oops have \NAME run builtin.
(pipeline): Filter-out #<unspecified> (xtrace residue).
This commit is contained in:
Jan Nieuwenhuizen 2018-10-30 07:09:29 +01:00
parent 3e8b021f0b
commit 1e5389f01d
1 changed files with 17 additions and 16 deletions

View File

@ -76,8 +76,8 @@
(escape-builtin? (and (string? program) (string-prefix? "\\" program))) (escape-builtin? (and (string? program) (string-prefix? "\\" program)))
(program (if escape-builtin? (string-drop program 1) program)) (program (if escape-builtin? (string-drop program 1) program))
(command (cons program (cdr command)))) (command (cons program (cdr command))))
(or (builtin command #:prefer-builtin? (and %prefer-builtins? (or (builtin command #:prefer-builtin? (or %prefer-builtins?
(not escape-builtin?))) escape-builtin?))
(cut apply (compose status:exit-val system*) command)))) (cut apply (compose status:exit-val system*) command))))
(else (lambda () #t)))) (else (lambda () #t))))
(exec (append-map glob args))) (exec (append-map glob args)))
@ -206,20 +206,21 @@
(shell-opt? "errexit")) (shell-opt? "errexit"))
(exit status)) (exit status))
status)) status))
(when (> %debug-level 1) (let ((commands (filter (lambda (x) (not (eq? x *unspecified*))) commands)))
(format (current-error-port) "pijp: commands=~s\n" commands)) (when (> %debug-level 1)
;; FIXME: after running a builtin, we still end up here with the builtin's result (format (current-error-port) "pijp: commands=~s\n" commands))
;; that should probably not happen, however, cater for it here for now ;; FIXME: after running a builtin, we still end up here with the builtin's result
(match commands ;; that should probably not happen, however, cater for it here for now
(((and (? boolean?) boolean)) (match commands
(handle boolean)) (((and (? boolean?) boolean))
(((and (? number?) number)) (handle boolean))
(handle number)) (((and (? number?) number))
(((? unspecified?)) (handle number))
(handle #t)) (((? unspecified?))
(((? unspecified?) t ... #t) (handle #t))
#t) (((? unspecified?) t ... #t)
(_ (handle (apply pipeline+ #t commands))))) #t)
(_ (handle (apply pipeline+ #t commands))))))
(define* (builtin ast #:key prefer-builtin?) (define* (builtin ast #:key prefer-builtin?)
;; FIXME: distinguish between POSIX compliant builtins and ;; FIXME: distinguish between POSIX compliant builtins and