Tips記事
» 2000年12月20日 00時00分 UPDATE

「Backspace」キーで前の文字が削除できない

[木田佳克,ITmedia]

 シェルなどで文字入力をしている際,「Backspace」キーで前の文字を削除できないことがないだろうか(例:hogehoge^H^H)。このような場合には,sttyの設定を見直してeraseへの関連付けを調べてみよう。

$ stty -a
speed 9600 baud; rows 55; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = ;
eol2 = ; 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
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

 上記リスト内で注目したいのは,「erase=^?」の項目である。「^?」は「Delete」キーを指すため,次のように指定して「Backspace」キーに変更すればよい。

$ stty erase ^H

Copyright © ITmedia, Inc. All Rights Reserved.

注目のテーマ