How to Read from stdin in Lisp Posted in Polyglotbits on 25 of Nov, 2015

Just as with reading program arguments - lisp looks a bit weird when reading from the stdin stream. That is until you get the hang of it.

(loop for line = (read-line *terminal-io* nil :eof)
     until (eq line :eof)
     do (write-line line))

We loop through each line read from the terminal-io stream. We tell it to not send an error when hitting eof (otherwise the program would crash). In the do step we just write-line the line to stdout.