Subj : Re: Using javascript as an interactive command language To : Robert Mecklenburg From : Brendan Eich Date : Tue Mar 30 2004 08:26 pm Robert Mecklenburg wrote: > I'm implementing an interactive (but scriptable) command language. > Expressions in this language look like: > > list all users > pushd key > set debug on > > I would like to use javascript as the basic interpreter for this > language, but I'm having trouble knitting my syntax together with js > syntax. > > I can imagine a bash-like behavior where things that don't immediately > look like javascript are handled by my own parser, while the rest is > handled by js. Of course, I'd like to be able to use variables from > js in my own commands. Like: > > list -l $users > > where $users is the contents of a js variable. > > Any suggestions on how to do this? Ancient progenitor versions of the js shell (http://lxr.mozilla.org/mozilla/source/js/src/js.c) used to preprocess the command line to turn list -l $users into list("-l", $users) or something like that. I wrote the hack, but I actually forget the details, and the code was removed long before mozilla.org released js/src into the open. Is it important to preprocess into JS? You'll find endless tension between the pre- and post-processed languages. Better to use pure JS, or something like pure bash. Mixing leaves you in a muddle, too often. /be .