Input Line Editing

der Mouse mouse at mcgill-vision.UUCP
Fri Aug 5 13:09:58 AEST 1988


In article <1988Jul22.203037.9092 at utzoo.uucp>, henry at utzoo.uucp (Henry Spencer) writes:
> In article <6339 at bloom-beacon.MIT.EDU> tytso at athena.mit.edu (Theodore Y. Ts'o) writes:
>> ... We have the line editor built into csh.  I maintain this is the
>> right thing to do...

(I didn't write the >> text, but I might have.  We, too, have editing
built into the csh, and I too maintain this is the right thing to have
done.  Not that it's the right ultimate solution, but that it's the
right thing to have done, given what we had to start with.)

> I trust you have put this into *all* the shells?  (Especially since
> the name of the shell which is closest to being a Unix-wide standard
> does not begin with "c".)

No, we don't have it in all the shells.  So?  Suppose I add a verbose
flag to, um, dd.  Does this now instantly leave me open to criticsm
because I didn't add the same flag to all other programs?

> Whatever happened to layers of abstraction?

Not workable at present.  Ideally, input editing should be divorced
from the shell.  *However*,

- The input editor must know whether it's talking to the shell or not.
   Primarily to keep input histories separate, secondarily to shift
   command sets (I, for example, want ^P as previous-line-of-history in
   the shell but SIGTSTP when running a program).

- The input editor must go away when the tty is in raw or cbreak mode.
   This means one ioctl per typed line in cooked mode (bearable) or per
   typed character in raw or cbreak (possibly bearable, but also
   possibly not).

- When speaking to the shell, the input editor must have access to
   things only the shell knows.  In particular, the shell's current
   directory, its current set of shell and environment variables and
   any bind commands that have been issued since the shell started.

None of these are insurmountable, given unlimited time to hack the
kernel (or extensive hacks to the shell, which amounts to merging the
shell and the input editor - see below).  However, very few, if any, of
us have this luxury.  And the only other programs we spend substantial
time typing at are editors, for which input line editing is
inappropriate (for those (few?) who use ed, there *is* ile).

Stop and think about it.  Are there any programs, besides the shell and
editors, that you spend much time typing to?  Of those, are there any
that do line-at-a-time input (as opposed to screen-oriented programs
like less, rogue, or hack)?  There certainly aren't in my case.

Now.  Tell me again, why was it wrong to put input editing into the
csh?  It solves the problem in a manageable amount of time, without
creating worse problems.  The only alternative I see is to build the
facilities of ile into the shell, so it is not only a shell but also a
full input editor for executed commands.  This may be workable, but I
suspect the use of a pty when unnecessary (eg, editors) will impose a
sometimes-unacceptable performance hit.  But if you want to try it,
feel free - a good shell rewrite plus general input editor would be a
very nice thing to have around.

					der Mouse

			uucp: mouse at mcgill-vision.uucp
			arpa: mouse at larry.mcrcim.mcgill.edu



More information about the Comp.unix.wizards mailing list