ash internals: evalstring() calls

David Fenyes dfenyes at thesis1.med.uth.tmc.edu
Sun Mar 31 08:00:02 AEST 1991


In article <1991Mar26.212622.757 at am.sublink.org> alex at am.sublink.org (Alex Martelli) writes:

>Here's the relevant portion from mash, my own ash dialect:
>
>		handler = &jmploc;
>		TRACE(("putprompt(%s)\n", prompter));
>		if (setjmp(jmploc.loc)) {
>			TRACE(("putprompt error recovery\n"));
>			popstackmark(&smark);
>			popfile();
>			p = 0;
>		} else {
>			setstackmark(&smark);
>			evalstring(prompter);
>			popstackmark(&smark);
>			p = lookupvar("__P");
>		}
>
>where "prompter" is a string I build up by catting __P=" in front of
>lookupvar("PS1"), and " after that.

My solution was very similar looking-- I call a function cheapexpand()
from putprompt in parser.c, which epands the ~/, then calls expandstr,
which cats up a similar string & calls evalstring in eval.c.

The problem I had was, of course, that syntax errors invoked error(),
which did a longjmp back to the main loop, which tried to parse the
offending string again.  Judicious local use of setjmp, INTON, and INTOFF
fixed the problem.

For those of us who use ash, it may be useful to pool information,
such as bug fixes, etc.  2 bugs I found are a bomb on an empty subshell
(), avoided by making an empty subshell a syntax error (I know it's a
kludge), and improper shell exiting from scripts in the -I mode, fixed
by including a `!top ||' in the test for exit on an EOF.

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



More information about the Comp.unix.shell mailing list