refuse a second input file
It was never read, and nothing said so.
This commit is contained in:
15
sexc.scm
15
sexc.scm
@@ -150,11 +150,14 @@
|
||||
(map string->symbol (string-split (cdr entry) ",")))
|
||||
(filter (lambda (entry) (eq? (car entry) 'features)) args)))
|
||||
|
||||
(define (get-input-file args)
|
||||
(let ((rest-args (get-rest-args args)))
|
||||
(if (null? rest-args)
|
||||
'stdin
|
||||
(car rest-args))))
|
||||
(define (get-input-file args dash?)
|
||||
(let ((inputs (append (if dash? (list "-") (list)) (get-rest-args args))))
|
||||
(cond ((null? inputs) 'stdin)
|
||||
;; any after the first were never read, and nothing said so
|
||||
((pair? (cdr inputs))
|
||||
(apply error "sexc compiles one input file at a time; given" inputs))
|
||||
(dash? 'stdin)
|
||||
(else (car inputs)))))
|
||||
|
||||
(define (stdout-output? output)
|
||||
(or (eq? output 'default) (equal? output "-")))
|
||||
@@ -270,7 +273,7 @@ status, which is ours to pass on."
|
||||
(output (get-arg args 'output 'default))
|
||||
(help (help-arg? args))
|
||||
|
||||
(input (if (stdin-dash? raw-args) 'stdin (get-input-file args)))
|
||||
(input (get-input-file args (stdin-dash? raw-args)))
|
||||
(current-dir (current-directory)))
|
||||
(call/cc
|
||||
(lambda (return)
|
||||
|
||||
@@ -80,6 +80,18 @@
|
||||
(and (zero? (car run)) (substring-index "main" (cadr run)) #t)))
|
||||
(change-directory scratch)
|
||||
|
||||
;;; the second was never read, and nothing said so
|
||||
(test-assert "a second input is refused"
|
||||
(let ((run (sexc-run #f hello hello "-C" "-o" "-")))
|
||||
(and (not (zero? (car run)))
|
||||
(substring-index "one input file at a time" (caddr run))
|
||||
#t)))
|
||||
(test-assert "stdin besides a file too"
|
||||
(let ((run (sexc-run hello-source "-" hello "-C" "-o" "-")))
|
||||
(and (not (zero? (car run)))
|
||||
(substring-index "one input file at a time" (caddr run))
|
||||
#t)))
|
||||
|
||||
(test "-o - is refused for an executable" #f
|
||||
(sexc-succeeds? hello "-o" "-"))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user