3

I have a configuration line in my .inputrc:

set enable-bracketed-paste on  # Insert paste as a string rather than possibly running it

This is valid when typed at the command line:

bind 'set enable-bracketed-paste on'

However the variable is not being set when I start bash v4.4.23.

Why is this line being ignored?

2 Answers 2

1

TL;DR:

Put comments on separate lines to configuration.

A comment at the end of a line causes readline to silently ignore the whole line if the line would otherwise be valid.


The manual does say:

Lines beginning with a ‘#’ are comments.

It doesn't say that a comment will cause an otherwise valid config line to be ignored.

This is strange, because the line:

set foobar on  # baz

Results in:

readline: /home/ravi/.config/readline/inputrc: line 34: foobar: unknown variable name

Meaning that lines with a # at the end of them are indeed parsed for validity. They're just ignored if they would otherwise be valid.

2
  • Note that it says "lines beginning with #". A line not with a # at the start may not be a comment and the # and the text after it will be part of the value.
    – Kusalananda
    Dec 10, 2018 at 9:52
  • 1
    @Kusalananda I agree with you, but when setting a variable to on # blah when its valid values are either on or off some sort of error message would be helpful.
    – Tom Hale
    Dec 11, 2018 at 1:09
1

The parser for readline doesn't seem to be that good:

 $ bind 'set "enable-bracketed-paste" "on" '; echo $?; bind -v | grep 'bracketed'
 0
 readline: "enable-bracketed-paste": unknown variable name

 $ bind 'set enable-bracketed-paste "on" '; echo $?; bind -v | grep 'bracketed'
 0
 set enable-bracketed-paste off

 $ bind 'set enable-bracketed-paste on '; echo $?; bind -v | grep 'bracketed'
 0
 set enable-bracketed-paste on

 $ bind 'set enable-bracketed-paste on .'; echo $?; bind -v | grep 'bracketed'
 0
 set enable-bracketed-paste off

It seems that any string after an option is seen as part of the option (maybe?).

The manual states that comments are only at the start of the line, so, I recommend you to stick to that rule. Instead, use:

 # Insert paste as a string rather than possibly running it
 set enable-bracketed-paste on
3
  • From the last example it seems that anything invalid will return the value to the default value.
    – Tom Hale
    Dec 11, 2018 at 9:34
  • Well, yes, for the enable-bracketed-paste option, but that is not the case for set bell-style off for example, it stays at the previous value when the line is not understood by readline, not falling to a default value. @TomHale
    – user232326
    Dec 11, 2018 at 9:38
  • readline: now with added randomness for increased surprises!
    – Tom Hale
    Dec 11, 2018 at 10:48

You must log in to answer this question.

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