(import magic-pipes) (import args) (import (chicken process-context)) (receive (options operands before-exprs after-exprs usage) (parse-mp-args (command-line-arguments) '() "procedure-expr" "Read s-expressions from standard input, applies the procedure-expr to them, and writes the returned values to standard output.") (unless (= (length operands) 1) (usage)) (let* ((expr (parse-code (car operands))) (ec (make-eval-context before-exprs (list expr) after-exprs)) (closure (eval-context-handler-closure ec 0))) (for-each-input-datum (lambda (input) (with-values-to-output (lambda () (without-ports (lambda () (closure input))))))) (without-input-port (eval-context-end-closure ec))))