Skip to content

fix(console): backspace deletes char not word in emacs keymap (#2209)#2251

Open
Moriz82 wants to merge 1 commit intoBishopFox:masterfrom
Moriz82:fix/console-backspace-word-delete
Open

fix(console): backspace deletes char not word in emacs keymap (#2209)#2251
Moriz82 wants to merge 1 commit intoBishopFox:masterfrom
Moriz82:fix/console-backspace-word-delete

Conversation

@Moriz82
Copy link
Copy Markdown
Contributor

@Moriz82 Moriz82 commented Apr 23, 2026

Bug

In the sliver console, pressing Backspace deletes the whole previous word. Type beaconss, hit Backspace, everything disappears instead of just the last s. Reported on Kali, but it hits any Linux terminal that sends \C-h (0x08) on Backspace.

Cause

vendor/github.com/reeflective/readline/internal/keymap/emacs.go has a table emacsKeys with a bad entry:

unescape(`\C-h`): {Action: "backward-kill-word"},

That line shadows the correct DefaultBinds() entry (\C-hbackward-delete-char). GNU readline convention: \C-h is single-char delete, \M-\C-h is word-kill. The override got it backwards.

Fix

Delete the one bad line. DefaultBinds() already has the right binding, and \M-\C-h (Meta-Backspace) still does word-kill.

 var emacsKeys = map[string]inputrc.Bind{
 	unescape(`\C-D`):     {Action: "end-of-file"},
-	unescape(`\C-h`):     {Action: "backward-kill-word"},
 	unescape(`\C-N`):     {Action: "down-line-or-history"},

Tested

Built on a Kali arm64 VM (6.18). Master deletes the whole word; patched binary deletes one char. Meta-Backspace still kills the word like it should.

Change lives in vendor/ per the "vendor changes in a distinct commit" rule.

Fixes #2209

…Fox#2209)

emacsKeys bound \C-h (ASCII 8, Backspace on some Linux terminals) to
backward-kill-word, shadowing the correct DefaultBinds() entry
(backward-delete-char). Readline convention: \C-h is single-char delete,
\M-\C-h is word-kill.

Remove the bad \C-h entry. DefaultBinds() handles it correctly, and
Meta-Backspace still binds to backward-kill-word via \M-\C-h.

Fixes BishopFox#2209

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Moriz82 Moriz82 requested a review from a team as a code owner April 23, 2026 19:25
@Moriz82 Moriz82 requested a review from kmathisbf April 23, 2026 19:25
@moloch--
Copy link
Copy Markdown
Collaborator

These edits will need to be in https://github.com/moloch--/readline the vendor/ directory is external dependencies we don't want to edit them directly from this repo.

@Moriz82
Copy link
Copy Markdown
Contributor Author

Moriz82 commented Apr 24, 2026

Thanks for the pointer, makes sense, I missed that vendor/ is generated. Opened a PR at https://github.com/moloch--/readline/pull/1 with the same fix and will cross-reference it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Backspace deletes entire word instead of single character in interactive console

2 participants