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

Bug #218637 reported by Jarno Suni
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
xkeyboard-config (Ubuntu)
Opinion
Wishlist
Unassigned

Bug Description

OS: from Hardy to at least Bionic.

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.

WORKAROUNDS:

Run
setxkbmap -option "nbsp:none"
to make <Alt Gr><space> type regular space character.

Even better option is to use "classic", "mac" or "nodeadkeys" keyboard variant instead of "". This could be set up in /etc/default/keyboard and maybe in configuration dialog in your desktop environment.

Non-breaking space can still be typed (in GTK apps) by <Ctrl><Shift>u 00a0<Enter>, if needed. Another option is to use compose key: <compose> <space> <space>.

In Bash scripts you could also use `printf '\u00a0'` or `printf '\xc2\xa0'` to print a non-breaking space. (You could use `echo -en` instead of `printf`.) Or you could set up a variable `readonly nbsp=$'\u00a0'`.

Yet another workaround would be to use a font that displays regular space and non-breaking space differently, but is there one?

Tags: pipe
Revision history for this message
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.

Revision history for this message
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

Revision history for this message
Jarno Suni (jarnos) wrote :

I am using the i386 version.

Revision history for this message
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

Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
Michael Nagel (nailor) wrote :

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

Revision history for this message
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?

Revision history for this message
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.

Revision history for this message
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

Revision history for this message
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".

Revision history for this message
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)
description: updated
Revision history for this message
Bryce Harrington (bryce) wrote : Re: [Hardy] Whitespace in command line not always regural whitespace

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
Revision history for this message
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
Revision history for this message
Jarno Suni (jarnos) wrote :

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

Revision history for this message
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.

Revision history for this message
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?

Revision history for this message
tp (torben-putkonen) wrote :

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

Revision history for this message
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
Revision history for this message
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.

Revision history for this message
Jarno Suni (jarnos) wrote :
Revision history for this message
Jarno Suni (jarnos) wrote :

I hope the attachments are worth the trouble.

Michael Nagel (nailor)
Changed in xorg:
status: Incomplete → New
Revision history for this message
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)
Changed in xorg:
status: New → Confirmed
Revision history for this message
Jarno Suni (jarnos) wrote :

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

Revision history for this message
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
Revision history for this message
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?

Revision history for this message
Timo Aaltonen (tjaalton) wrote :

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

Revision history for this message
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'.

Revision history for this message
Jarno Suni (jarnos) wrote :

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

Revision history for this message
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.

Revision history for this message
Jarno Suni (jarnos) wrote :

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

Jarno Suni (jarnos)
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.
Revision history for this message
Jarno Suni (jarnos) wrote : Re: 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.
Revision history for this message
Jarno Suni (jarnos) wrote : Re: Non-breaking space is easy to write accidentally and impossible to distinguish from regular space.

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

Revision history for this message
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.

Revision history for this message
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.

Jarno Suni (jarnos)
description: updated
Jarno Suni (jarnos)
summary: - Non-breaking space is easy to write accidentally and impossible to
- distinguish from regular space.
+ Non-breaking space is easy to write accidentally and impossible or hard
+ to distinguish from regular space.
Jarno Suni (jarnos)
description: updated
Revision history for this message
Timo Aaltonen (tjaalton) wrote :

you'd need to file this upstream

affects: xorg (Ubuntu) → xkeyboard-config (Ubuntu)
Changed in xkeyboard-config (Ubuntu):
importance: Undecided → Wishlist
status: Invalid → Opinion
Jarno Suni (jarnos)
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.