[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: You said the J word
> Well, Byron and Paul, how were you thinking of implementing a rewritable
> read-eval loop? Let's look at that, and see what facilities we might need
> to write a job-control system in an ES script.
oh, something like
fn-forever = while {}
catch @ e msg {
if {~ $e error} {
echo >[1=2] $msg
} {
echo >[1=2] uncaught exception: $e $msg
}
throw retry
} {
forever {
if {!~ $#fn-prompt 0} {
prompt
}
local (cmd = <>{%parse $prompt}) {
if {~ $#cmd 0} {
break
}
$cmd
}
}
}
for the default interactive loop. possible additions:
- additional special exceptions (sigwinch, maybe)
- print of bad or non-0 statuses
- additional hooks like prompt
- anything you feel like
i can't promise that the above code will work in 0.75, but something like it
will. if you notice, the only thing that's missing for this to work is %parse is
not exposed yet. also, we haven't decided whether it's only the interactive repl
that is redefinable or both interactive and non-interactive. if it's both,
they'll probably be available under different names, with a strong recommendation
to not change the non-interactive one.
other open issues:
- is history handled inside this loop? (probably yes)
- what happens when the user hits return at the prompt,
with just an empty line. (probably %parse does not return
and reprompts)
as to job control, if you can figure out how to do it, great, but i'm not sure i
believe it's possible. i'd be happy to be proven wrong, but my guess is that
really supporting job control is going to require work throughout the shell.