Read stdin to string in Newlisp

44 Views Asked by At

How do you read the entire contents of standard input into a string in Newlisp? (i.e the entire remaining contents after the current read position - this operation is commonly called "slurp file")

1

There are 1 best solutions below

0
On BEST ANSWER

You can use this:

(define (read-all)
  (let (r "" ch "")
      (while (setf ch (read-char))
        (setf r (append r (char ch))))
    r))

See also: http://www.newlisp.org/downloads/newlisp_manual.html#read-char