Non-breaking space is easy to write accidentally and impossible to distinguish from regular space.

Bug #218637 reported by Jarno Suni on 2008-04-17
22
This bug affects 3 people
Affects Status Importance Assigned to Milestone
GNOME Terminal
New
Undecided
Unassigned
Geany
New
Undecided
Unassigned
gedit
New
Undecided
Unassigned
nano
New
Undecided
Unassigned
xfce4-terminal
New
Undecided
Unassigned
xorg (Ubuntu)
Undecided
Unassigned

Bug Description

OS: from Hardy to at least Trusty.

When you use Finnish keyboard, you have to hold Alt Gr down to type | or \ or certain other characters. When typing a shell command, you may often want to enter a space character after such characters. But it easily happens that Alt Gr is still down when you press space, and consequently you type non-breaking space character U+00A0 (at least, if you use UTF-8 keyboard layout, which is default in Ubuntu).

$cd /tmp ; echo 0 > foo\ bar ; ls "foo bar"
ls: cannot access foo bar: No such file or directory
$cat foo bar | grep 0
No command ' grep' found, but there are 16 similar ones
 grep: command not found

Besides it may be hard to see the typing error, as non-breaking space character looks exactly same as regular space character.

A way to avoid such typos would be to use another keyboard shortcut for non-breaking space. Besides non-breaking space should look different than regular space in terminal emulators and in editors.

A workaround in to run
setxkbmap -option "nbsp:none"
to make <Alt Gr><space> type regular space character,
and use `printf '\u00a0'` or `printf "\xc2\xa0"` to have a non-breaking space in scripts and in command line.

Non-breaking space can be typed (in GTK apps) by <Ctrl><Shift>u 00a0<Enter>, if needed, but it looks exactly like a regular space.
For me, <Super><Space> would be a good shortcut for non-breaking space.

Jarno Suni (jarnos) wrote :

Is there possibility that hard disk is working unreliably? Is there a way to check the drive? It has ext3 filesystem.

t3r0 (t3r0) wrote :

I can confirm this!

Clean install of Hardy 64bit.

tero2@tero-desktop:~$ lspci | grep VGA
bash:  grep: command not found
tero2@tero-desktop:~$

tero2@tero-desktop:~$ ls -l / | grep home
bash:  grep: command not found

tero2@tero-desktop:~$ ls -l / | /bin/grep home
bash:  /bin/grep: No such file or directory

tero2@tero-desktop:~$ echo "mooo" | cowsay
bash:  cowsay: command not found

Jarno Suni (jarnos) wrote :

I am using the i386 version.

crwl (crwl) wrote :

Are you sure you aren't inserting an altgr+space character after the pipe character instead of just the normal space? I'm suspecting this because there is an additional empty space after "bash: (somecommand): command not found"

If grep wasn't found, bash would say:
bash: grep: command not found
you are seeing:
bash: grep: command not found

crwl (crwl) wrote :

Looks like Flyspray ate the double space from my previous comment. Anyway, you are seeing double empty space after the first colon in the bash error message, which you shouldn't.

Jarno Suni (jarnos) wrote :

crwl, you are right about the altgr+space character. But it didn't matter in ubuntu 7.10 terminals xterm and xfce4-terminal tested. Why is the change? I guess I'll have to quit using any space there.

Michael Nagel (nailor) wrote :

under system -> preferences -> keyboard -> layouts -> layout options you can choose what shift+space should do. marking this as invalid.

Jarno Suni (jarnos) wrote :

The bug is not about shift+space, but altgr+space. You can not configure it in Xubuntu's desktop environment. Can anybody tell why is the effect of altgr+space changed in (X)ubuntu 8.04?

Michael Nagel (nailor) wrote :

i am sorry about invalidating your bug! feel free to reopen the bug and file it against the relevant packages. this greatly increases the chance of being noticed by the right guys.

Juhamatti Niemelä (iiska) wrote :

Problem seems to be in keyboard layout. ie. AltGr + space produces different byte sequence in us- and fi-layouts. This can be verified with following commands. (In both cases the space between quotes is typed by pressing AltGr+space)

$ setxkbmap us
$ echo " " | hexdump
0000000 0a20
0000002

$ setxkbmap fi
$ echo " " | hexdump
0000000 a0c2 000a
0000003

Juhamatti Niemelä (iiska) wrote :

I did a little more searching and found out, that altgr+space behaviour can be altered with xkb option nbsp. Adding following line to the keyboard InputDevice section in xorg.conf avoids this issue by disabling the nbsp.

Option "XkbOptions" "nbsp:none"

In KDE systems this can be done alternatively by going to System Settigns -> Regional & Language -> Keyboard layout -> Xkb Options, and selecting option "Space key outputs usual space at any level." for "Using space key to input non-breakable space character".

Jarno Suni (jarnos) wrote :

Thanks Juhamatti Niemelä for the hack. I think it would be user-friendly that identically looking commands work same way by default, too.

Jarno Suni (jarnos) on 2008-09-16
description: updated

Hi jarnos,

Please attach the output of `lspci -vvnn`, and attach your /var/log/Xorg.0.log file from after reproducing this issue. If you've made any customizations to your /etc/X11/xorg.conf please attach that as well.

Changed in xorg:
status: New → Incomplete
Michael Nagel (nailor) wrote :

i think the above was a bulk reply and does not apply here, because those settings do not matter here at all. it is more a design question in x (or perhaps rather in your virtual terminal application or your shell or whereever) if it is good to have chars that look exactly the same but behave completely different. like 1 and I and l or O and 0, but just for whitespace (tab vs nl vs space vs nbsp ...)

Changed in xorg:
status: Incomplete → New
Jarno Suni (jarnos) wrote :

Michael Nagel, 1, I and l look different in terminal, also 0 and O.

Michael Nagel (nailor) wrote :

i know. this bug is about whitescreen. the other chars were just a example to make clear what you mean (it is your bug, isnt it?). because Bryce' request does not make much sense in this case.

tp (torben-putkonen) wrote :

This feature can be configured in:
System
  ->Preferences
  ->Keyboard
  ->Layouts
  ->Layout options...
  ->Using space key to input non-breakable...

Few issues:

 * Changing the configuration option from "Default" to "Space key outputs usual space at any level" does not have any effect on my computer. AltGr+Space in gnome-terminal still outputs nbsp.
 * What does "Default" mean?

tp (torben-putkonen) wrote :

For some reason Juhamatti Niemelä's XkbOptions do not work either.

Bryce Harrington (bryce) wrote :

Hi jarnos,

Please attach the output of `lspci -vvnn`, and attach your /var/log/Xorg.0.log file from after reproducing this issue. If you've made any customizations to your /etc/X11/xorg.conf please attach that as well.

Changed in xorg:
status: New → Incomplete
Jarno Suni (jarnos) wrote :

Hi bryceharrington,

I don't understand why you are asking all the attachments, but I hope you tell. Please note that I could patch the problem by customizing xrog.conf as presented at https://bugs.launchpad.net/ubuntu/+source/xorg/+bug/218637/comments/11. However, the customazion is commented out in the attachment to reproduce the issue.

Jarno Suni (jarnos) wrote :
Jarno Suni (jarnos) wrote :

I hope the attachments are worth the trouble.

Michael Nagel (nailor) on 2008-11-02
Changed in xorg:
status: Incomplete → New
Jarno Suni (jarnos) wrote :

I tested under Xubuntu 8.10. Problem continues to exist; furthermore the xorg.conf setting featured by Juhamatti Niemelä does not work there, I suppose, since "InputDevice" sections are ignored there AFAIK.

I suppose the GUI way to configure does work in Gnome, but I can't find such option in Xfce4's keyboard preferences.

Bryce Harrington (bryce) on 2008-12-05
Changed in xorg:
status: New → Confirmed
Jarno Suni (jarnos) wrote :

tp, "Space key outputs usual space at any level" works here in ubuntu 8.10 (Gnome session).

Timo Aaltonen (tjaalton) wrote :

The change was made to conform standards. The Finns of you can read the details here:

http://kotoistus.tksoft.com/linux/space.html

if the app doesn't show the difference, then it's a bug in the app, not X.

Changed in xorg:
status: Confirmed → Invalid
Jarno Suni (jarnos) wrote :

Timo Aaltonen, can you tell me which terminal does not have such a bug then? Or should shells interpret non-breaking space as normal space?

Timo Aaltonen (tjaalton) wrote :

I don't know. Maybe needs wider discussion than possible on this bug.

Saku Ytti (ubuntu-ip) wrote :

Just to point out, that correct solution to disabling NBSP is
[ytti@sci ~]% cat /etc/hal/fdi/policy/remove_nbsp.fdi
<?xml version="1.0" encoding="UTF-8"?>
<deviceinfo version="0.2">
  <device>
    <match key="info.capabilities" contains="input.keys">
      <merge key="input.x11_options.XkbOptions" type="string">nbsp:none</merge>
    </match>
  </device>
</deviceinfo>
[ytti@sci ~]%

Instead of mocking with xorg.conf. This requires restart of hal and xorg. If you do not wish to restart
immediately but still wish to disable nbsp you should issue 'sudo setxkbmap -option "nbsp:none'.

Jarno Suni (jarnos) wrote :

Thanks, Saku Ytti. The command is 'sudo setxkbmap -option "nbsp:none"' to be strict.

Jarno Suni (jarnos) wrote :

At least in ubuntu 14.04 (with Xfce) you don't need to be superuser to run
setxkbmap -option "nbsp:none"
I run this as an autostarted application to avoid trouble.

Jarno Suni (jarnos) wrote :

And as for the first workaround in #28, my system does not even have /etc/hal/

Jarno Suni (jarnos) on 2015-02-02
description: updated
summary: - [Hardy] Whitespace in command line not always regural whitespace
+ Non-breaking space is easy to write accidentally and hard to distinguish
+ from regular space.

As for apps mentioned in #25, the list is big. Libreoffice shows the difference, but I don't know other programs.

summary: - Non-breaking space is easy to write accidentally and hard to distinguish
- from regular space.
+ Non-breaking space is easy to write accidentally and impossibel to
+ distinguish from regular space.
summary: - Non-breaking space is easy to write accidentally and impossibel to
+ Non-breaking space is easy to write accidentally and impossible to
distinguish from regular space.
Jarno Suni (jarnos) wrote :

Is there any font that would display non-breaking space differently?

Seppo Enarvi (senarvi) wrote :

I make the mistake regularly of writing a non-breaking space instead of a regular space, when writing shell scripts. It produces errors that are very difficult to detect.

Jarno Suni (jarnos) wrote :

geany has setting in Edit > Preferences > Editor > Display > Show white space.
I think it should be default. It shows one pixel mark for regular white space, which is hard to see, though. It shows just space for non breaking space. Inverting colors helps a bit.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers