[comp.sources.d] ash internals: evalstring

dfenyes@thesis1.med.uth.tmc.edu (David Fenyes) (03/26/91)

Ash is certainly an undersold shell;  for its power and flexibility,
it's remarkably small.  I was able to port ash to Coherent, a v7
variant, with little difficulty, and because Coherent won't run atty,
I added a command line editor & history.  I want to be able to expand
variables in PS1, and also execute the contents of the variable EVERY
befor each prompt.  To do this, I call the function evalstring in eval.c.
This works perfectly for valid expressions, but if there is a syntax error,
the shell goes into an infinite loop, reporting the error endlessly.

When the pre-existing code calls evalstring (for example, with the contents
of SHINIT at startup) an error is reported once and evaluation is terminated
properly.  I have studied these invokations and can't find the difference.

Is there anyone out there familiar with the internals of ash that can offer
some insight?.

Also, did anyone notice that a () (empty subshell) at the command line
gives funny results (on my system it caused a reset).  I avoided this
by returning a syntax error on an empty subshell. (Obviously a kludge).

Thanks a lot-- BTW, if anyone wants to alpha test this adaptation of ash,
please contact me.  If you currently use ash and don't have atty, or use
sh and wish you had ksh, this may be an improvement.  Personally, I think
ash is every bit as powerful and not as huge as ksh.

David.
--
David Fenyes                                  dfenyes@thesis1.hsch.utexas.edu
University of Texas Medical School            Houston, Texas