When I delete a "word" in Bash, it will stop at certain characters like _
and /
. For example, if I type
/foo/bar
and activate backward-kill-word
(typically mapped to Alt–Backspace and/or Ctrl–w), the remaining text is
/foo/
. This does not correspond to $COMP_WORDBREAKS
or readline
's rl_completer_word_break_characters
. How can I detect (preferably in a running system, rather than the defaults in the code, since they presumably can be overridden) which characters are used to determine word breaks?
Best Answer
The bash documentation states:
And
The handling of
backward-word
in Bash 4.2 is done in the bundled libreadline code (text.c:rl_backward_word
). The word break is based onrl_alphabetic
, which itself relies on theisalnum
function. This is locale-dependent, but not configurable directly in bash.Note that Bash 4.0 introduced another "word" type with the
shell-forward-word
andshell-backward-word
actions (and kill equivalents). These break only on shell meta-characters (()<>;&|"
) and blanks (possibly locale dependant viaisblank
), handled in the main bash code (bashline.c
).