Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a strange problem with inserting backslashes (Ubuntu 10.10 and 11.04, the upgrade changed nothing). The key combination on my keyboard (Swedish Thinkpad T400) is AltGr + ?. However, this seems not to be the problem, as it only appears with some programs.

With for instance bash 4.2, python 2.7, python 3.2, swipl 5.10 I cannot type nor copy-paste backslash into the terminal. With ash, csh, ghci, nano, vi, idle, idle3 everything behaves as expected, I can both type and copy-paste. For instance, copying

echo gurka\\\\agurk

(four literal backslashes) and pasting it into csh (and then hitting enter), I get

$ csh
% echo gurka\\\\agurk
gurka\\agurk

but with bash, I get

$ echo gurkaagurk
gurkaagurk

Unfortunately, I noticed first quite a while after many new installations and I can't tell when it first appeared. I suspect a bug or conflicting configuration of some library common to the first group but not to the second, but I am unsure on how to go on. It is extremely annoying and I am grateful for hints.

UPDATE: the behaviour is the same for konsole and whatever you get with Ctrl-Alt-F1 (which is what I had tested). It also does not work with gnome-terminal and xterm, but these two indicate error (by flashing). Ideas about what to check?

UPDATE: Problem is solved, thanks to Gilles! It was a misconfiguration of the readline library (.inputrc)

Marcus

share|improve this question
    
What terminal are you using? May help to identify where the problem is. –  user17311 May 11 '11 at 14:10
    
I have here hardy+lucid+natty and all do this echo gurka\\\\agurk shows gurka\\agurk –  Rinzwind May 11 '11 at 14:19
    
How do you do copy/paste? Did you use right-click and paste (in GUI)? I suspect you have a foreign keyboard? Try changing the keyboard layout to a keyboard that matches your keyboard. –  user17311 May 11 '11 at 14:32
    
Thanks for the suggestions. I have a Swedish keyboard and a Swedish keyboard layout and this has not changed for several years. This is also not the problem, since as stated in the question, I can type or paste backslash into some terminal-based programs (using Shift+Ctrl+V in Konsole). –  Marcus May 11 '11 at 14:56
    
But, it is very likely the problem because the issues you describe are almost always associated with foreign keyboards (and keyboard layouts). An upgrade may have changed your layout, or the behavior of said layouts. –  user17311 May 11 '11 at 15:33

1 Answer 1

up vote 6 down vote accepted

I think the programs you're using all use the readline library to read input. So I guess you've misconfigured the readline library. The system configuration file is /etc/inputrc and the per-user file is ~/.inputrc. You probably put one backslash too much in a binding, so that instead of binding a command to an escape sequence you've bound it to a sequence beginning with a backslash.

Right:  "\e[1;5C": forward-word  (escape sequence sent by Ctrl+Left)
Wrong:  "\\e[1;5C": forward-word  (\ e [ 1 ; 5 C)

If the problem was only in bash, the problematic binding would be in ~/.bashrc. Note that in .bashrc, that binding above would be written bind "\\e[1;5C: forward-word", with two backslashes because bash does a round of backslash expansion before passing the definition down to readline. (bind '\e[1;5C: forward-word' would also work, since backslashes lose their special meaning within single quotes.)

share|improve this answer
    
You were absolutely right! Thank you very much! I guessed so much but I didn't know where to look. (Although, as a detail, it seems I did have .inputrc exactly as what you term "Right", with only one initial backslash. Here it is: Tab: complete #Rebind some keys Ctrl-b: backward-word Ctrl-f: forward-word \e[1;5D : backward-word \e[1;5C : forward-word However, as far as I am concerned, the problem is solved -- I don't need any of the last two bindings. After removing them, logging out, loggin in everything worked.) –  Marcus May 11 '11 at 18:55
    
@Marcus: Comments can't have newlines, so your comments are hard to read. If you need further help, edit your question. (Also, please remove the first comment since the second one supersedes it.) But from what I see, you're missing the double quotes around the escape sequences. "\e[1;5C" makes \e stand for the escape character; without the double quotes, \e[1;5c has a backslash standing for itself. –  Gilles May 11 '11 at 19:02
    
Yes, I am new here, just trying to get the hang of the formatting (I have already without intention sent several half-baked comments). Also, you were right, the problem boiled down to missing double-quotes. I will look around as how to mark the problem as solved for the benefit of other owners of corrupt .inputrc –  Marcus May 11 '11 at 19:08
    
@Marcus: To mark the question as solved, click the check mark to the left of one of the answers (the one that helped you most). There's no point in putting the solution in your question: that's what the answers are for. –  Gilles May 11 '11 at 19:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.