aboutsummaryrefslogtreecommitdiff
path: root/run-command.h
diff options
context:
space:
mode:
authorThomas Rast <trast@student.ethz.ch>2011-05-17 17:19:08 +0200
committerJunio C Hamano <gitster@pobox.com>2011-05-17 20:44:17 -0700
commitb5cc003253c8e1b505d5a2fbbcecb1ffcb409758 (patch)
tree1433f9ee41fee1a42bce53842c941769792d2eee /run-command.h
parentea1ab4b280ed3b041da53e161e32e38930569f3e (diff)
downloadgit-b5cc003253c8e1b505d5a2fbbcecb1ffcb409758.tar.gz
git-b5cc003253c8e1b505d5a2fbbcecb1ffcb409758.tar.xz
add -i: ignore terminal escape sequences
On the author's terminal, the up-arrow input sequence is ^[[A, and thus fat-fingering an up-arrow into 'git checkout -p' is quite dangerous: git-add--interactive.perl will ignore the ^[ and [ characters and happily treat A as "discard everything". As a band-aid fix, use Term::Cap to get all terminal capabilities. Then use the heuristic that any capability value that starts with ^[ (i.e., \e in perl) must be a key input sequence. Finally, given an input that starts with ^[, read more characters until we have read a full escape sequence, then return that to the caller. We use a timeout of 0.5 seconds on the subsequent reads to avoid getting stuck if the user actually input a lone ^[. Since none of the currently recognized keys start with ^[, the net result is that the sequence as a whole will be ignored and the help displayed. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'run-command.h')
0 files changed, 0 insertions, 0 deletions