295 lines
11 KiB
HTML
295 lines
11 KiB
HTML
<!--startcut ======================================================= -->
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
|
<html>
|
|
<head>
|
|
<META NAME="generator" CONTENT="lgazmail v1.3C.e">
|
|
<TITLE>The Answer Guy 51: ksh Keybindings (vi Keys)</TITLE>
|
|
</HEAD><BODY BGCOLOR="#FFFFFF" TEXT="#000000"
|
|
LINK="#3366FF" VLINK="#A000A0">
|
|
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
|
|
<H4>"The Linux Gazette...<I>making Linux just a little more fun!</I>"</H4>
|
|
<P> <hr> <P>
|
|
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
|
|
<center>
|
|
<H1><A NAME="answer">
|
|
<img src="../../gx/dennis/qbubble.gif" alt="(?)"
|
|
border="0" align="middle">
|
|
<font color="#B03060">The Answer Guy</font>
|
|
<img src="../../gx/dennis/bbubble.gif" alt="(!)"
|
|
border="0" align="middle">
|
|
</A></H1>
|
|
<BR>
|
|
<H4>By James T. Dennis,
|
|
<a href="mailto:linux-questions-only@ssc.com">linux-questions-only@ssc.com</a><BR>
|
|
LinuxCare,
|
|
<A HREF="http://www.linuxcare.com/">http://www.linuxcare.com/</A>
|
|
</H4>
|
|
</center>
|
|
|
|
<p><hr><p>
|
|
<!-- endcut ======================================================= -->
|
|
<!-- begin 18 -->
|
|
<H3 align="left"><img src="../../gx/dennis/qbubble.gif"
|
|
height="50" width="60" alt="(?) " border="0"
|
|
>ksh Keybindings (vi Keys)</H3>
|
|
|
|
|
|
<p><strong>From Robert Lynch on Sun, 20 Feb 2000
|
|
</strong></p>
|
|
<!-- ::
|
|
ksh Keybindings (vi Keys)
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
:: -->
|
|
<P><STRONG>
|
|
Hi-
|
|
</STRONG></P>
|
|
<P><STRONG>
|
|
My wife is an SCO sys admin whose business bought her a Dell
|
|
pre-configured RH 6.0 box for home use. She's used to ksh on SCO, with
|
|
default vi setting. She finds this broken with bash. I have tried
|
|
to fix it, including installing pdksh, but no joy.
|
|
</STRONG></P>
|
|
<P><STRONG>
|
|
Say she types:
|
|
</STRONG></P>
|
|
<Pre><STRONG>$ ls
|
|
$ who
|
|
</STRONG></Pre>
|
|
<P><STRONG>
|
|
then hits ESC + up arrow. Instead of moving through the command
|
|
history, a "[A" character appears. I tried re-mapping the arrow keys
|
|
but nada.
|
|
</STRONG></P>
|
|
<P><STRONG>
|
|
Please NOTE: I've been working on this for a while, and have seen
|
|
several postings, to the effect "just set -o vi". Ain't this!
|
|
</STRONG></P>
|
|
<P><STRONG>
|
|
TIA. Bob L.
|
|
</STRONG></P>
|
|
<BLOCKQUOTE><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
|
|
HEIGHT="28" WIDTH="50" BORDER="0"
|
|
>
|
|
<tt>set -o vi</tt> under bash works fine for me. I've used it
|
|
occasionally and I've had students use it for years.
|
|
</BLOCKQUOTE>
|
|
<BLOCKQUOTE>
|
|
However, vi normally uses the letters h,j,k, and l for its
|
|
cursor controls. The [Up Arrow] and other keys are not
|
|
traditional vi key bindings (though most modern versions of
|
|
vi will also accept them if your terminal is properly
|
|
configured using the appropriate <tt>TERM</tt> variable in
|
|
association with a decent terminfo or termcap entry).
|
|
</BLOCKQUOTE>
|
|
<BLOCKQUOTE>
|
|
Can you run '<tt>vi</tt>' (the editor) and/or emacs or xemacs from
|
|
this command prompt? Is it in an xterm or from a text
|
|
console? Are you (and she) accessing this through telnet?
|
|
What terminal emulation is this going through?
|
|
</BLOCKQUOTE>
|
|
<BLOCKQUOTE>
|
|
If you can run '<tt>vi</tt>' or '<tt>emacs</tt>' within that terminal window,
|
|
or console/terminal session then your <tt>TERM</tt> environment
|
|
setting should be sufficient to support the vi keybindings
|
|
used by bash, pdksh and ksh). My quick tests with pdksh, ksh
|
|
'93, and bash all show that the [Up Arrow] key IS recognized
|
|
by the vi keys handlers in any of them. I tested this from
|
|
a text console with <tt>TERM=linux</tt>, from under the '<tt>screen</tt>'
|
|
utility with <tt>TERM=screen</tt>, and from an xterm with <tt>TERM=xterm</tt>.
|
|
This is all on a <A HREF="http://www.debian.org/">Debian</A>/Potato system
|
|
with all recent updates applied for all software (yesterday).
|
|
</BLOCKQUOTE>
|
|
<BLOCKQUOTE>
|
|
So I don't know what is wrong. You'll want to play with the
|
|
'k' (vi up key) to see if that works, and play with the TERM
|
|
variable (especially if you're connecting through your net
|
|
using some MS-DOS or MS-Windows telnet client). You might
|
|
also want to check if you are using some unusual key
|
|
mappings on your Linux console (the loadkeys command) or in
|
|
your copy of X (the xmodmap command). Again, if you have
|
|
vi and emacs working normally, then these should not be
|
|
problems for you.
|
|
</BLOCKQUOTE>
|
|
<BLOCKQUOTE>
|
|
Moving on to the larger issues of making your wife feel at
|
|
home on here new system. If she's used to SCO's ksh then
|
|
she might find some of the minor differences between it and
|
|
GNU bash (the default Linux shell, from the Free Software
|
|
Foundation --- <A HREF="http://www.gnu.org"
|
|
>http://www.gnu.org</A>). There are even
|
|
differences between pdksh and ksh '93, and even more minor
|
|
ones between pdksh and ksh '88.
|
|
</BLOCKQUOTE>
|
|
<BLOCKQUOTE>
|
|
I don't know which ksh ships with SCO UNIX nor even which
|
|
version of SCOnix that your wife is using. I'll assume
|
|
she's using a recent copy, and that it shipped with the most
|
|
recent Korn shell.
|
|
</BLOCKQUOTE>
|
|
<BLOCKQUOTE>
|
|
I suppose the best advice would be to get the real Korn
|
|
Shell (ksh '93) from David G. Korn's web site:
|
|
<A HREF="http://www.kornshell.com"
|
|
>http://www.kornshell.com</A>. Just follow a couple of obvious
|
|
links (Software, "Official AT&T Release...") and fill out
|
|
the little form.
|
|
</BLOCKQUOTE>
|
|
<BLOCKQUOTE>
|
|
Note that this is NOT free for commercial use. It is also
|
|
NOT open source. You can read their license agreement for
|
|
all of the details.
|
|
</BLOCKQUOTE>
|
|
<BLOCKQUOTE>
|
|
If your use will be within those restrictions than you can
|
|
get this for your wife. If she's used to subtle nuances of
|
|
ksh --- and especially if she does serious shell scripting
|
|
involving associative arrays, co-processes, and floating
|
|
point mathematics then she'll be happier with the "real
|
|
thing" then she will be with bash or pdksh.
|
|
</BLOCKQUOTE>
|
|
<BLOCKQUOTE>
|
|
Most shell users wouldn't know the difference. However, ksh
|
|
'93 (the most recent major release of the package) is the
|
|
"king" of Unix command shells. It has a number of features
|
|
which are unique to it (particularly in support of
|
|
associative arrays).
|
|
</BLOCKQUOTE>
|
|
<BLOCKQUOTE>
|
|
There's a pretty good, and short, article co-authored by the
|
|
creator of the Korn shell that discusses some of the
|
|
features that make ksh '93 unique which was published by the
|
|
Linux Journal and can be read on their web site at:
|
|
</BLOCKQUOTE>
|
|
<BLOCKQUOTE><BlockQuote>
|
|
<A HREF="http://www2.linuxjournal.com/cgi-bin/frames.pl/lj-issues/issue27/korn.html"
|
|
>http://www2.linuxjournal.com/cgi-bin/frames.pl/lj-issues/issue27/korn.html</A>
|
|
</BlockQuote></BLOCKQUOTE>
|
|
<BLOCKQUOTE>
|
|
More information about pdksh can be found at the web site of
|
|
its current maintainer, Michael Rendell at:
|
|
</BLOCKQUOTE>
|
|
<BLOCKQUOTE><BlockQuote>
|
|
<A HREF="http://www.cs.mun.ca/~michael/pdksh"
|
|
>http://www.cs.mun.ca/~michael/pdksh</A>
|
|
</BlockQuote></BLOCKQUOTE>
|
|
<BLOCKQUOTE>
|
|
As far as I know pdksh and ksh are the only shells to
|
|
support co-processes. So, if your wife uses those she'll
|
|
definitely want to use one of them. Bash doesn't seem to
|
|
support co-processes, yet. I think it's on their wishlist.
|
|
</BLOCKQUOTE>
|
|
<BLOCKQUOTE>
|
|
(For those that don't know: Co-processes work something
|
|
like this:
|
|
</BLOCKQUOTE>
|
|
|
|
<blockquote><pre> $ bc |&
|
|
[1] 12345
|
|
$ print -p '1234 * 4567890'
|
|
$ read -p result
|
|
$ echo $result
|
|
|
|
...
|
|
|
|
$ print -p quit
|
|
$
|
|
[1] + Done bc
|
|
$
|
|
</pre></blockquote>
|
|
<BLOCKQUOTE>
|
|
I started a copy of the "big calculator" (bc). The |&
|
|
operator makes it a "co-process" --- running with its
|
|
stdin (standard input file stream) connected to one
|
|
pipe from ksh/pdksh and its stdout (standard output
|
|
file stream) connected to another. Then I printed
|
|
a value into that special co-process pipe (print -p)
|
|
and read that value back out (using read -p). I can
|
|
then print other transactions into this co-process and
|
|
read other results from it. This allows me to have
|
|
one process loaded, maintaining state, and available
|
|
for work. In shells that don't support co-processes
|
|
I'd have to maintain my own state, and keep re-executing
|
|
this command (possibly with quite a bit of extra
|
|
over-head in providing my intermediate results/state
|
|
back to the new instance of the program).
|
|
</BLOCKQUOTE>
|
|
<BLOCKQUOTE>
|
|
So, co-processes are one of the more interesting innovations
|
|
of the Korn shell. Such things are relatively easy to do
|
|
from C, but ksh and pdksh are the only shells that
|
|
interactively provide these at a high level shell prompt.)
|
|
</BLOCKQUOTE>
|
|
|
|
<!-- sig -->
|
|
|
|
|
|
<!-- end 18 -->
|
|
<!--startcut ======================================================= -->
|
|
<P> <hr> <P>
|
|
<H5 align="center"><a href="http://www.linuxgazette.com/copying.html"
|
|
>Copyright ©</a> 2000, James T. Dennis
|
|
<BR>Published in <I>The Linux Gazette</I> Issue 51 March 2000</H5>
|
|
<H6 ALIGN="center">HTML transformation by
|
|
<A HREF="mailto:star@tuxtops.com">Heather Stern</a> of
|
|
Tuxtops, Inc.,
|
|
<A HREF="http://www.tuxtops.com/">http://www.tuxtops.com/</A>
|
|
</H6>
|
|
<P> <hr> <P>
|
|
<!-- begin tagnav ::::::::::::::::::::::::::::::::::::::::::::::::::-->
|
|
<TABLE WIDTH="95%"><TR VALIGN="center" ALIGN="center">
|
|
<TD colspan="2" rowspan="2"><A
|
|
HREF="../lg_answer51.html"
|
|
><IMG SRC="../../gx/dennis/answernew.gif"
|
|
ALT="[ Answer Guy Current Index ]"></A>
|
|
<TD colspan="2" rowspan="2"><A
|
|
HREF="../../tag/kb.html"
|
|
><IMG SRC="../../gx/dennis/answertoc.gif"
|
|
ALT="[ Index of Past Answers ]"></A></td>
|
|
<TD WIDTH="11%"><A HREF="../lg_answer51.html#greeting"><img
|
|
src="../../gx/dennis/smily.gif" alt="greetings" border="0"></A></TD>
|
|
<TD WIDTH="11%"><A HREF="1.html">1</A></TD>
|
|
<TD WIDTH="11%"><A HREF="2.html">2</A></TD>
|
|
<TD WIDTH="11%"><A HREF="3.html">3</A></TD>
|
|
<TD WIDTH="11%"><A HREF="4.html">5</A></TD>
|
|
</TR><TR VALIGN="center" ALIGN="center">
|
|
<TD WIDTH="11%"><A HREF="5.html">5</A></TD>
|
|
<TD WIDTH="11%"><A HREF="6.html">6</A></TD>
|
|
<TD WIDTH="11%"><A HREF="7.html">7</A></TD>
|
|
<TD WIDTH="11%"><A HREF="8.html">8</A></TD>
|
|
<TD WIDTH="11%"><A HREF="9.html">9</A></TD>
|
|
</TR><TR VALIGN="center" ALIGN="center">
|
|
<TD WIDTH="10%"><A HREF="10.html">10</A></TD>
|
|
<TD WIDTH="10%"><A HREF="11.html">11</A></TD>
|
|
<TD WIDTH="10%"><A HREF="12.html">12</A></TD>
|
|
<TD WIDTH="10%"><A HREF="13.html">13</A></TD>
|
|
<TD WIDTH="11%"><A HREF="14.html">14</A></TD>
|
|
<TD WIDTH="11%"><A HREF="15.html">15</A></TD>
|
|
<TD WIDTH="11%"><A HREF="16.html">16</A></TD>
|
|
<TD WIDTH="11%"><A HREF="17.html">17</A></TD>
|
|
</TR><TR VALIGN="center" ALIGN="center">
|
|
<TD WIDTH="10%"><A HREF="18.html">18</A></TD>
|
|
<TD WIDTH="10%"><A HREF="19.html">19</A></TD>
|
|
<TD WIDTH="10%"><A HREF="20.html">20</A></TD>
|
|
<TD WIDTH="10%"><A HREF="21.html">21</A></TD>
|
|
<TD WIDTH="11%"><A HREF="22.html">22</A></TD>
|
|
</TR></TABLE>
|
|
</TR><TR VALIGN="center" ALIGN="center">
|
|
<!-- end tagnav ::::::::::::::::::::::::::::::::::::::::::::::::::::-->
|
|
<P> <hr> <P>
|
|
<!-- begin lgnav ::::::::::::::::::::::::::::::::::::::::::::::::::: -->
|
|
<A HREF="../index.html"
|
|
><IMG SRC="../../gx/indexnew.gif" ALT="[ Table Of Contents ]"></A>
|
|
<A HREF="../../index.html"
|
|
><IMG SRC="../../gx/homenew.gif" ALT="[ Front Page ]"></A>
|
|
<A HREF="../lg_bytes51.html"
|
|
><IMG SRC="../../gx/back2.gif" ALT="[ Previous Section ]"></A>
|
|
<A HREF="../../faq/index.html"
|
|
><IMG SRC="../../gx/dennis/faq.gif"
|
|
ALT="[ Linux Gazette FAQ ]"></A>
|
|
<A HREF="../lg_tips51.html"
|
|
><IMG SRC="../../gx/fwd.gif" ALT="[ Next Section ]"></A>
|
|
<!-- end lgnav ::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
|
|
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
|
|
</BODY></HTML>
|
|
<!--endcut ========================================================= -->
|