mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix emacs backslash escaping behavior (#179)
This commit fixes the following:
1. Emacs mode ignores --nobackslashctrl (re: 24598fed
) when in
reverse search.
2. When entering more than one backslash, emacs reverse search mode
deletes multiple backslashes after pressing backspace once.
Reproducer:
$ set --emacs --nobackslashctrl
$ <Ctrl+R> \\\\<Backspace>
3. Except when in reverse search, the backslash fails to escape a
subsequent interrupt character (^C). Reproducer:
$ set --emacs --backslashctrl
$ teststring \<Ctrl+C>
src/cmd/ksh93/edit/emacs.c:
- Disable escaping backslashes in emacs reverse search if
'nobackslashctrl' is enabled.
- Fix the buggy behavior of backslashes in emacs reverse
search by processing backslashes in a loop.
src/cmd/ksh93/tests/pty.sh:
- Add regression tests.
src/cmd/ksh93/sh.1:
- Fix a minor documentation error (^C is the usual interrupt
character, not ^?).
Co-authored-by: Martijn Dekker <martijn@inlv.org>
This commit is contained in:
parent
fe74702766
commit
a282ebc8fe
6 changed files with 65 additions and 12 deletions
|
@ -640,5 +640,35 @@ r ^/dev/null\r\n$
|
|||
r ^:test-2:
|
||||
!
|
||||
|
||||
# err_exit #
|
||||
((SHOPT_ESH)) && [[ -o ?backslashctrl ]] && tst $LINENO <<"!"
|
||||
L nobackslashctrl in emacs
|
||||
|
||||
d 10
|
||||
w set -o emacs --nobackslashctrl
|
||||
|
||||
# --nobackslashctrl shouldn't be ignored by reverse search
|
||||
p :test-2:
|
||||
w \cR\\\cH\cH
|
||||
r ^:test-2: \r\n$
|
||||
!
|
||||
|
||||
# err_exit #
|
||||
((SHOPT_ESH)) && tst $LINENO <<"!"
|
||||
L emacs backslash escaping
|
||||
|
||||
d 10
|
||||
w set -o emacs
|
||||
|
||||
# Test for too many backslash deletions in reverse-search mode
|
||||
p :test-2:
|
||||
w \cRset\\\\\\\\\cH\cH\cH\cH\cH
|
||||
r ^:test-2: set -o emacs$
|
||||
|
||||
# \ should escape the interrupt character (usually Ctrl+C)
|
||||
w true \\\cC
|
||||
r true \^C
|
||||
!
|
||||
|
||||
# ======
|
||||
exit $((Errors<125?Errors:125))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue