Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!bcm!lib!thesis1.med.uth.tmc.edu From: dfenyes@thesis1.med.uth.tmc.edu (David Fenyes) Newsgroups: comp.unix.shell Subject: Re: ash internals: evalstring() calls Message-ID: <4892@lib.tmc.edu> Date: 30 Mar 91 22:00:02 GMT References: <4879@lib.tmc.edu> <1991Mar26.212622.757@am.sublink.org> Sender: usenet@lib.tmc.edu Organization: University of Texas Medical School at Houston Lines: 40 Nntp-Posting-Host: thesis1.hsch.utexas.edu In article <1991Mar26.212622.757@am.sublink.org> alex@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@thesis1.hsch.utexas.edu University of Texas Medical School Houston, Texas