Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: What's a superjob?



On 2018-09-26 10:42:00 -0700, Bart Schaefer wrote:
> On Wed, Sep 26, 2018 at 8:51 AM Peter Stephenson
> <p.stephenson@xxxxxxxxxxx> wrote:
> >
> > Now we have just one process running: the main shell, and vi.  Suppose
> > you hit ^Z.  Then vi suspends.  The main shell is in the middle of
> > running e, but it's not supposed to finish doing that till vi exits.
> > But without special action we're now back at the top-level shell prompt
> > and it never will execute.
> 
> To add a bit more color here ... in the absence of this special
> handling, when vi is suspended, the shell has two choices:
> 1) treat vi as successfully completed and continue executing the function, or
> 2) treat vi as failed and stop the function at this point.
> 
> IIRC different shells have historically made different decisions about
> this.  I believe zsh's original behavior was #1, but that led to
> problems if (in this type of example) the remainder of the function
> depends on the content of the edited file.  So #2 avoids side-effects,
> but causes at minimum annoyance because now you have a suspended vi
> but the rest of the function is simply gone.

But if the goal of the rest of the function is to modify the current
shell environment, this is just like if it were gone. Couldn't zsh
avoid the extra fork and immediately ask the user what to do?
For instance: continue in foreground (avoiding the extra fork),
do the extra fork, interrupt the function in some way.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



Messages sorted by: Reverse Date, Date, Thread, Author