2007年7月12日

sqlplus 里 backspace 键的映射

登到远端 redhat + Oracle 10g,
进入 SQLPLUS 里面按 backspace 键不能删除字符,总是不停的出现 ^H ,

修改 Gnome-Terminal 里的“兼容性设置”,
将“按 backspace 产生” 从 “ctrl+H” 改成 “ASCII DEL”,再按 backspace 可以删除前面的字符了,
可是到了AIX上面又不行了,在 ksh/vt100下面全是 ^?

后来在网上找到一个修正的办法:

Add the following line to your .login file:
    stty erase ^H
This will make backspace work correctly in your sqlplus session.

将 stty erase ^H 加入到启动脚本(如 redhat 的 .bash_profile,或 .profile等 )即可解决

stty 是用来显示和修改虚拟终端特殊键键值定义的,这是一个历史遗留问题。
最早的终端键盘只有标准的ASCII键,所以UNIX对键码的应用非常谨慎,仔细想想 VI 为什么要用 hjkl 作为光标移动键,而不用上下左右?就是这个原因了!

用 stty -a 可以看到当前的扩展键值定义和其它传输属性:
speed 38400 baud; rows 24; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?;
swtch = M-^?; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc ixany imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke



没有评论: