bash命令后键盘的奇怪行为

时间:2015-09-19 05:59:19

标签: linux bash gnome-terminal terminal-emulator

我有一个正常运行的bash脚本文件。我在该文件中添加了一些行,并开始使用bash调试器bashdb调试我的bash脚本。 bashdb正常运行,没有任何问题。直到我到达以下命令行:

mapfile -t newdirs < <( ( for i in "${newpath[@]:$start:$((stop-start))}"; do echo "$i"; done )|awk 'BEGIN{FS="/: "; ORS=$'\n';} {print substr($0, index($0, $2))"\n";}')

在我的脚本中是#116行。这是我要经历的步骤:

$ bashdb myscript.sh
bash debugger, bashdb, release 4.2-0.8

Copyright 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Rocky Bernstein
This is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.

(/path/to/myscript.sh:20):
20: if [ -n "$1" ]
bashdb<0> c 116
One-time breakpoint 1 set in file /path/to/myscript.sh, line 116.
(/path/to/myscript.sh:116):
116:          mapfile -t newdirs < <( ( for i in "${newpath[@]:$start:$((stop-start))}"; do echo "$i"; done )|awk 'BEGIN{FS="/: "; ORS=$'
';} {print substr($0, index($0, $2))"
";}')
bashdb<1> s
(/path/to/myscript.sh:116):
116:          mapfile -t newdirs < <( ( for i in "${newpath[@]:$start:$((stop-start))}"; do echo "$i"; done )|awk 'BEGIN{FS="/: "; ORS=$'
';} {print substr($0, index($0, $2))"
";}')
awk 'BEGIN{FS="/: "; ORS=$'
';} {print substr($0, index($0, $2))"
";}'
(/path/to/myscript.sh:116):
116:          mapfile -t newdirs < <( ( for i in "${newpath[@]:$start:$((stop-start))}"; do echo "$i"; done )|awk 'BEGIN{FS="/: "; ORS=$'
';} {print substr($0, index($0, $2))"
";}')
for i in "${newpath[@]:$start:$((stop-start))}"
bashdb<2> bashdb<(2)> 

之后我的键盘在bashdb正在运行的终端窗口中无法正常工作。我必须按两次或更多次,或者甚至按住它几秒钟才能在终端窗口上回显。例如,我按三次 q ,但它只回显一个q个字母。之后我按 Enter 一次,显示:

** Undefined command "qqq". Try "help".

有时它根本不会显示我按下的按键(即使按住它几秒钟后),按 Enter 后显示:

** Undefined command "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq". Try "help".

它的作用就像我的键盘硬件损坏或尘土飞扬,但事实并非如此。它在其他窗口中正常工作!

这种奇怪的行为只存在于终端窗口和其他窗口键盘中正常工作。如果通过按 q 然后按 Enter bashdb退出成功,则奇怪的行为仍然在该终端内。唯一的解决方案是关闭终端窗口并按 Ctrl + Alt + T 重新打开一个新的终端窗口。我尝试了很多次,这种奇怪的行为完全发生在我脚本的第116行。

注意:
我发现它与我脚本的那一行没有直接关系。如果我在bashdb中按 Ctrl + C,也可能会出现这种奇怪的行为。

0 个答案:

没有答案