5

It looks like at random times my keyboard inserts a character that is displayed as a space character but isn't one, preventing the shell from interpreting it correctly. For example before "sort" below :

yannick@yannick-ubuntu:~/Pictures/Photos$ ls | grep "2015" | sort
No command ' sort' found, did you mean:
 Command 'psort' from package 'radiance' (universe)
 Command 'sort' from package 'coreutils' (main)
 Command 'tsort' from package 'coreutils' (main)
 Command 'msort' from package 'msort' (universe)
 sort: command not found

If I go back in history, delete the "bad" space and write another one, then the command works fine :

yannick@yannick-ubuntu:~/Pictures/Photos$ ls | grep "2015" | sort
20150101
20150103
20150107
20150109
20150111
20150115

Any ideas what happens ?

I enter all my commands using keyboard (no copy / paste), I am using gnome terminal on ubuntu 14.04, and I have a french (azerty) keyboard.

  • Are you using the AltGr key to enter the pipe? I think you might have to press space twice. Once to end the symbol input and then once for the regular space. – chaskes May 14 '15 at 18:33
5

Actually I figured it out ! When I press AltGr + Space, a non-breaking space is inserted, which looks exactly like a space... but isn't one.

On a french keyboard, the pipe character is inserted using AltGr + 6. What happens is sometimes the AltGr is still down when I press the Space, which is why this "bad" space character is inserted.

This problem has a bug report on launchpad. The suggested solution is to use the following command so that no non-breaking spaces are inserted :

setxkbmap -option "nbsp:none"

To do it permanently, I added the line in .bashrc and it works fine ! Note that doing it in .profile doesn't work (I guess if it's not in .bashrc the shell overrides it at startup)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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