On Wed, Oct 25, 2017 at 09:48:14AM -0400, Chet Ramey wrote: > On 10/22/17 6:52 PM, Aron Griffis wrote: > > I'm seeing some strange behavior and don't know if it's a bug or intended. > > > > Reproducer: > > 1. env INPUTRC=/dev/null bash --norc > > 2. set -o vi > > 3. true --foo=bar > > 4. up arrow, then left arrow to put the cursor on the equals sign > > 5. press ctrl-w, nothing happens > > Posix says the word boundaries for ^W in insert mode are characters that > aren't <blank> or <punct>. So you deal with the character before the > cursor (`o'), and delete to a character that isn't <blank> or <punct>. > Since the `o' is in neither character class, it's the word boundary, and > you don't delete anything. FWIW, ksh93 behaves the same way (but beeps > annoyingly). [...]
Wow. I had to read the POSIX description of ^W a few times to finally understand how this works. Thank you for the explanation Chet! Patch for compatibility with ksh93 (just kidding!): diff --git a/lib/readline/vi_mode.c b/lib/readline/vi_mode.c index 3cb7e8c9..210d1b12 100644 --- a/lib/readline/vi_mode.c +++ b/lib/readline/vi_mode.c @@ -1615,7 +1615,14 @@ rl_vi_unix_word_rubout (int count, int key) rl_point--; } - rl_kill_text (orig_point, rl_point); + if (orig_point == rl_point) + { + rl_ding(); + } + else + { + rl_kill_text (orig_point, rl_point); + } } return 0;