3

I was swapping some readline settings in my .bashrc earlier today and mistyped the following (bind since it's not in .inputrc):

bind "mark-symlinked-directories on"

I forgot to put a set in there before mark-symlinked-directories, the end result of which was that my "d" key stopped working in the terminal. Lame. Some messing around with other bindings indicated that whatever the first letter of the last "word" was would be unusable, i.e.,

bind "page-completions off" messed up c

bind "visible-stats on" messed up s

bind "completion-query-items 42" messed up i

My question is why? What is bind doing that renders those keys useless, and why that specific key?

1
  • 1
    Weird! I just tried this and get the same behavior. Note that D does actually work, it is just not printed. For example, Ctrl+D to exit the shell works as expected despite not being able to type D.
    – terdon
    Commented Feb 17, 2014 at 13:56

1 Answer 1

2

While I cannot provide an answer why this happens, it seems that if the 1st token of the readline command contains one or several dashs (-), then the character following the last dash will be unbound from the self-insert command.

e.g. the following will disable the p key.

bind foo-bar-paz zill-honk
4
  • 1
    I haven't checked the source to confirm, but I think I know why. Readline parses the argument as MODIFIER1-MODIFIER2-MAINKEY, ignores unknown modifiers, and treats the first character of MAINKEY as the key. This looks like insufficient input validation, not at all like intended behavior. Commented Feb 17, 2014 at 23:31
  • @Gilles If you can find something to back that up would you make it a separate answer so I can credit you?
    – Amory
    Commented Feb 19, 2014 at 15:15
  • @Amory This would require reading the source or checking the bug list. I don't have time for either at the moment. I actually encourage you to check the bug list, and if you find nothing, report this as a bug. Commented Feb 19, 2014 at 15:27
  • The reason why is at unix.stackexchange.com/a/477511/5132 .
    – JdeBP
    Commented Apr 23, 2020 at 23:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .