[plt-scheme] What's the latest on the Scsh port?
Eli Barzilay <eli at barzilay.org> writes at 18:20 12-Jul-2003 -0400:
> I generally plan to start working on some better support for shell
> scripts (an ideal would be to add some other grammar that will make
> the whole thing something you can use as an interactive shell...).
Neat. I thought very briefly about making a Scheme-based
TTY-command-line interactive shell for Unix, used in lieu of
sh/csh/ksh/bash/zsh/etc. The only thoughts I had were...
One very simple thing would be for the command line parser to read the
first regexp in the line, and if it's a symbol bound to a procedure,
than evaluate the input as if it were surrounded by parens.
(Alternatively, the command prompt could initialize the input to "()"
and leave the point in the middle, I suppose.)
The reader would read input across multiple lines til the sexps balance.
If the first read sexp is an exclamation point, the rest of the line is
treated as a conventional shell command without any Scheme, except that
backquoted expressions would be in our special Scheme shell syntax (and
could begin with "!" themselves). The command prompt could do
convenient things like insert a space after "!" if a non-space is typed
there.
I'd try to use one of the portable and solid but minimal Unix shells as
a starting point to get the esoterica of TTY ownership, process groups,
etc. on different Unices right. Perhaps the Unix implementation of
Plan9's "rc", if that turns out to be rock-solid? This starting point
might be stripped down to a few hundred lines of reused C code, or even
wholly rewritten once exactly what must be done is understood.
Ideally, it could be a separate MzScheme executable that has extra
frequently-needed modules already loaded, doesn't normally need to read
extra files at startup, and puts much of its VM footprint into a shared
library (perhaps a dumped image, a la Emacs?). There's also much to be
said for a login shell being self-contained as a single "/bin/mzsh"
file.
If you undertake writing an MzScheme-based interactive shell, I might
find time to hack on some interactive conveniences for it, like fancy
argument completion. I just don't have time for the upfront hard work
of the base shell.
Oh, extension in Scheme via a "~/.mzsh" file is of course imperative,
and where I think the actual win of a Scheme-based shell happen.
I would also keep in mind that at some point this interactive command
shell might be incorporated into an mzwm... :)
> My general idea is that some scripting support is desperately needed,
MzScheme is already good for "scripting", as far as I've noticed. For
Unix, it just could use a few more Posix functions. Maybe a few more
conveniences for running external programs and filtering their output
(e.g., an "expect" like tool), but I haven't really missed this. I did
suggest a simple regexp-binding macro in the PLT bug report system; that
or something better (perhaps with the binding names integrated into a
sexp-based regexp syntax?) would be useful for shell scripting.
(Although I still think that the conventional shell scripting paradigm
of chaining shell programs together with lots of haphazard parsing glue
should die a quick but painful death, which would eliminate a lot of the
need for regexps.)
I still really like how Python .py/.pyc and Emacs .el/.elc file pairs
work, but I guess MzScheme's "compiled" subdir and "setup-plt -l" are
close to as convenient for scripts.
The only two hesitations I've had about using MzScheme for scripting
are: (1) I currently only have MzScheme from CVS installed, and I've
broken it for a day 2 or 3 times; (2) every machine I use would need to
have PLT installed for my scripts to work. Both of these issues are
mostly resolved for me, now that a recent version of MzScheme is in
Debian.
--
http://www.neilvandyke.org/