[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ^Z signal



actually, job control in es is much harder than job control elsewhere,
i think, which is one of the reasons we haven't put in the primitives.

to give you an idea of what i mean, let's take a simple example:

	touch foo; sleep 100; rm foo

now, run this in a job controlling shell.  type control-z (or whatever
character you use) during the sleep.  what happens?

i've seen three answers, depending on which shell you use:

	(a) the control-z is ignored
	(b) the sleep is stopped, and if it is continued (fore- or
	    background), the ``rm foo'' is ignored.
	(c) the sleep is stopped and the rm happens right away

note that i've found no shell which does

	(d) the sleep is stopped, and when it is continued, the
	    rm is executed

the reason that no shell does (d) is not that it's the wrong thing
(after thinking about it, it's really the only right answer) but it's
very hard to do.

i can come up with worse examples.  (try suspending backquoted commands,
or replace the ``rm foo'' above with an assignment to a shell variable.)
even worse, functions (in shells that support them) look like multiple
commands separated by semicolons.

the problem with job control for es is that everything just looks
like an es command.  there is no separation *at the language level*
between the internal things and the external ones.  the read-eval-print
loop is written in es itself, so how do you distinguish it from
a shell function?  if you don't implement job control in es as (d),
it just won't work at all, because the whole shell looks like one
convoluted shell command.

but, wait, i hear Scott Schwartz yelling, if you just pass a continuation
for the stopped job to the signal handler, you can make it all work.  well,
yes, maybe you could, but es doesn't have first-class continuations, and
there's still the problem of where it goes when it's done, and all sorts
of problems still remain.  (one of these days, if i live long enough, es
may have first-class continuations, but it's going to happen for the next
couple of years.)

the offer still stands, by the way.  if you can make job control in es
work, more power to you, and if can be done in a small number of primitives
with little change to the rest of the shell, we'll conditionally include it.

but... i think you won't be able to get job control working in es without
doing (d), and i think that the only way (d) can be done is with first-class
continuations.  now, if you can get answer (a) through some hackery which
i can't quite picture, great.  because so much of es is done in shell
functions, however, (b) and (c) are really not useful enough to consider.

paul