Interlude: Scheme command-line tool idea
While I'm preparing a long Python-vs-Scheme post, here's a bit of filler. :-)
Check this. No, not the part about Common Lisp; what I'm interested in right now, is the snippet of Awk code, and the question whether a similar tool can be written in Scheme.
To put it more precisely, would it be possible to have a command-line tool, using Scheme as its language (and probably written in Scheme as well), that lets users write one-line queries like that?
It would be a cool thing to have, although I'm not sure if nested parentheses mix so well with the command line. Writing Scheme code in an editor is different from writing it at a shell prompt.
The Awk example could look something like this:
<name> '(begin (set-fs! ":")) (if (equal? $6 "/sbin/nologin") (print $1))' /etc/passwd
(It would have to use some reader manipulation to allow for expressions like $6 meaning (field 6), or something like that. Chicken already uses the $, so maybe a different syntax would be preferable.)
In any case, I am pondering this. The idea is to have a tool that is powerful, relatively easy to use, and still Scheme-y. Of course, the world probably doesn't need a new Awk, but I am exploring this idea as a coding/design exercise.
John Cowan said,
January 26, 2008 @ 6:24 am
Definitely check out scsh first; it's meant for writing scripts, not for interactive use, but it has excellent support for Posix, for an S-expression-based language (distinct from, but interoperable with, Scheme) for creating and manipulating process pipelines, and even an embedded Awk (available in Chicken as the awk egg).
Hans Nowak said,
January 26, 2008 @ 8:48 am
Thanks... I am aware of scsh (and was wondering if I should have mentioned it in the post), but I found it somewhat... unapproachable. That said, I'll give it a second look.