zsh-workers
 help / color / mirror / code / Atom feed
From: Stephane Chazelas <Stephane_Chazelas@yahoo.fr>
To: zsh-workers@sunsite.dk,
	Samuel Thibault <samuel.thibault@ens-lyon.org>,
	478019@bugs.debian.org
Subject: Re: Bug#478019: zsh: Should handle non-breaking space as word separator
Date: Sat, 26 Apr 2008 20:09:56 +0100	[thread overview]
Message-ID: <20080426190956.GA9225@sc.homeunix.net> (raw)
In-Reply-To: <20080426150548.GB6165@scru.org>

On Sat, Apr 26, 2008 at 04:05:48PM +0100, Clint Adams wrote:
> On Sat, Apr 26, 2008 at 12:00:03PM +0100, Samuel Thibault wrote:
> > Hello,
> > 
> > On a french keyboard, '|' is typed by using alt-gr, and the non-breaking
> > space is often typed by using alt-gr space. That often leads to this:
> > 
> > € echo a | grep a
> > zsh: command not found:  grep
> > 
> > Because zsh looks for a " grep" command, with leading non-breaking space
> > because my thumb remained a bit too long on the alt-gr key.
> > 
> > This doesn't happen with bash, because bash treats non-breaking space as
> > a word separator.  Could zsh do the same? (currently, I have defined
> > alias  grep=grep
> > alias  vi=vi
> > ...)
> 
> Having locale-based (and multibyte) word separators sounds like a nightmare
> to me, but maybe someone has some ideas.

Having the shell syntax that depends on the environment looks
like a very bad idea to me (think of scripts!).

There are already problems like that such as

case $x in
  ([a-z]) ...;;
esac

which is locale dependent while in most cases it's not what you
want. And to work around that is a nightmare POSIXly like:

LC_ALL=C command eval 'case $x in ([a-z]) ... esac'
(which doesn't even work in some shells because of bugs).

Another bad example which is causing more harm than benefit:

in ksh93, the decimal point is locale dependent, so you can't
do:

float Pi=3.14159265359

which is a syntax error is some locales:
$ LC_ALL=fr_FR ksh93 -c 'float Pi=3.141592653589'
ksh93[1]: typeset: 3.141592653589: arithmetic syntax error

This one is even harder to overcome:

$ LC_ALL=fr_FR ksh93 -c '
  LC_ALL=C command float Pi=3.141592653589; print $Pi'

$ LC_ALL=fr_FR ksh93 -c 'LC_ALL=C command eval float Pi=3.141592653589
 print $((Pi))'
ksh93: line 2: 3.141592653589: arithmetic syntax error

LC_ALL=fr_FR ksh93 -c 'in_C_locale() { typeset LC_ALL=C; eval "$@"; }
in_C_locale float Pi=3.141592653589; echo $LC_ALL;  print $((Pi))'
C
3.141592653589

All of which look like bugs to me.

Anyway, my point was to say that it's a bad idea to have the
syntax of the shell dependant on the locale.

-- 
Stéphane


      parent reply	other threads:[~2008-04-26 19:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20080426110003.GA16650@implementation>
2008-04-26 15:05 ` Clint Adams
2008-04-26 15:25   ` Samuel Thibault
2008-04-26 18:41   ` Peter Stephenson
2008-04-26 19:09   ` Stephane Chazelas [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080426190956.GA9225@sc.homeunix.net \
    --to=stephane_chazelas@yahoo.fr \
    --cc=478019@bugs.debian.org \
    --cc=samuel.thibault@ens-lyon.org \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).