Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #15747 > unrolled thread
| Started by | Koichi Murase <myoga.murase@gmail.com> |
|---|---|
| First post | 2019-12-19 00:43 +0800 |
| Last post | 2019-12-19 00:43 +0800 |
| Articles | 1 — 1 participant |
Back to article view | Back to gnu.bash.bug
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH] Fix a problem `rl_bind_key' cannot create shadow binding for `C-@' Koichi Murase <myoga.murase@gmail.com> - 2019-12-19 00:43 +0800
| From | Koichi Murase <myoga.murase@gmail.com> |
|---|---|
| Date | 2019-12-19 00:43 +0800 |
| Subject | [PATCH] Fix a problem `rl_bind_key' cannot create shadow binding for `C-@' |
| Message-ID | <mailman.1091.1576687436.1979.bug-bash@gnu.org> |
[Multipart message — attachments visible in raw view] — view raw
This is another report. Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -g -O2 -Wno-parentheses -Wno-format-security uname output: Linux hp2019 5.2.13-200.fc30.x86_64 #1 SMP Fri Sep 6 14:30:40 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu Bash Version: 5.0 Patch Level: 11 Release Status: maint Description: One of the public interface of readline, the function `rl_bind_key (key, function)' does not work with key = 0 (C-@) when there are already bindings of keyseqs starting from "\C-@". This is because when `rl_bind_key' calls `rl_generic_bind', it fails to construct an appropriate untranslated keyseq for "\C-@". Repeat-By: The function `rl_bind_key' is not widely used by current Bash codes, but to see the problem caused by this bug, one can use an older form of bind 'C-SPC:...' to register a shadow binding. $ LANG=C ./bash-3a7c642e --norc $ bind '"\C-@\C-@":"hello"' $ bind 'C-SPC:backward-char' $ echo* #<-- <C-@> (* is the cursor position) In the above example, the expected result is `ech*o' with `*' being the cursor position after the timeout, but the cursor does not move. But with the following newer form, we can get the expected result: $ LANG=C ./bash-3a7c642e --norc $ bind '"\C-@\C-@":"hello"' $ bind '"\C-@":backward-char' Fix: I attach a patch `0001-....patch'. In the patch, the key '\0' is treated specially similarly to the key '\\'. By the way I think there is a memory leak in the same function. Could you check the second attached patch `0002-....patch'? I think if the original binding is a macro the memory block should be released before the pointer is overwritten. Actually I'm not quite sure, but at least in a similar function `rl_generic_bind', the macro string is released. I think there is a memory leak also in the `rl_generic_bind'. The shadow macro which is stored in `map[ANYOTHERKEY].function' is not released before the overwrite. See the third patch `0003-....patch'. Thank you, Koichi
Back to top | Article view | gnu.bash.bug
csiph-web