scheme shell
about
download
support
resources
docu
links
 
scsh.net

From: Olin Shivers <shivers@lambda.ai.mit.edu>
Subject: Why we program in scsh
Newsgroups: comp.lang.scheme.scsh
Date: 31 May 1997 17:15:38 -0400
Organization: Artificial Intelligence Lab, MIT
Message-ID: <qijenanqr5x.fsf@lambda.ai.mit.edu>


Every now and then, a friend of mine sends me choice bits of Unix scripting
which I occasionally translate into scsh for comparison. Below I append the
latest example, courtesy Barak Pearlmutter.
    -Olin

;;; Copy IN to OUT, prefixing each line with a timestamp,
;;; or, as we say in AWK,
;;; awk '{"date '"'"'+%b %e %T'"'"'" | getline d; 
;;;      close("date '"'"'+%b %e %T'"'"'"); print d, $0}'
;;;
;;; Quiz: why is the close() necessary?
;;;     -Olin 
;;;      May 1997

(define (add-date in out)
  (while (not (eof-object? (peek-char in)))
    (format out "~a ~a\n"
	    (format-date "~b ~d ~H:~M:~S" (date)) ; E.g., "Sep 3 22:43:11"
	    (read-line in))))

Up