ksh availability

Mark Horton mark at cbosgd.UUCP
Thu Mar 14 08:07:09 AEST 1985


I've used the Korn shell also, and in general I think it's an excellent
piece of code.  Even though it comes from AT&T, there is full support for
4BSD job control, if you are on a 4BSD machine.  It's nearly identical to
the job control in csh, except that you have to restart foreground jobs
with "fg" instead of "%" (but fg works with csh too, so I just got in
the habit of typing "fg".)

In order for people not to get the wrong impression, there are two things
I want to make sure you are aware of.  The first is that ksh is quite
large - my VAX binary is 77K of text (the same size as csh), compared
to 26K for sh.  This doesn't seem to matter on a machine with paging,
but if you have a small machine or your machine doesn't page you may
see some performance differences.

The other thing is the way history is done.  If you use history as a way
to correct typos and remember or repeat that complicated command you did
15 commands ago, you'll love ksh.  You actually get your choice of vi or
emacs, in a one-line mode at the bottom of your screen, or you can do an
ed style substitution command.  (It's also possible to arrange that you
get put into vi's open mode, or your favorite editor.)  It does all this
without the foggiest idea what kind of terminal you are on, although it
only works on CRT's that don't overstrike.

If you use history as a way to save keystrokes, you may not feel the same
way.  I use the !$, !^, and !* features of vi constantly to save typing
effort (although I set my history character to , rather than ! because it's
easier to type and doesn't get in the way of UUCP commands.)  My fingers
know, at the reflexive level, that if I'm not sure what to type, the right
thing to type is ",$", which gets me the last argument to my previous command.
The user interface to the Korn shell history is completely different from
csh, and there is no direct substitute for this kind of piece-of-the-last-
command substitution.  The way you change a previous command is to go into
your editor (e.g. if you're a vi user, hit ESC, if you're an EMACS user,
just type a control letter) and you're in (an emulation of) your editor.
You can hit the "previous line" command (k or ^P) to go back in your
history list until you find the command you want, then go right to the
place you want to change, make the change, and hit return.  The return
key takes you out of the editor, and causes the shell to execute the
command (the whole thing, including the part to the right of the cursor.)
While this is very straightforward and natural, it does take a lot more
keystrokes than csh for many parameter substitution things.

Also, ksh does not have the tcsh tenex-style "escape recognition" feature,
and since it uses ESC to put you into vi (or as META for EMACS) there is
no obvious way to have both features present in either csh or ksh.

Finally, since ESC is meaningful to ksh, and since there is no System V
equivalent to the ctlecho stty bit that Berkeley has, there is no way to
stop the ESC you type from getting echoed to the terminal.  Since most
terminals do unpredictable things with ESC (like begin escape sequences)
this can cause problems.  I think the Korn shell echoes some more stuff
that it expects to cancel the current command, but this may not work on
all terminals.  It's not a problem on Berkeley UNIX.  The proper fix would
be to put ctlecho into the System V tty driver, but that's another battle.



More information about the Comp.unix mailing list