Zsh Mailing List Archive
Messages sorted by:
Re: [PATCH] [[:blank:]] only matches on SPC and TAB
- X-seq: zsh-workers 42773
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- Subject: Re: [PATCH] [[:blank:]] only matches on SPC and TAB
- Date: Mon, 14 May 2018 13:34:25 +0100
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=7cphk/q93EN/woL5x9eiZiLqHHccMfbtPcyJw0msWfE=; b=i1EXYfyYFYbZB2pIOkfrhgm35+gG0yrtCMKg+Z1dyHGcgAG4sD4m+CeOlJZvg88+nE tXziu0rX5QXdhwMYxeMyvqIisiZ2Wm5glHMp+zkZfV6nP7LFdElwN2uHkVIz6E1ivvRB i9YO+3ubAVDtI4v3im5p8LjLiaASBHXAM7+C2WWs2jopUBER30HrNpxcgJ2jIreR9ovl xjDCbBE2c+W/PDbDiLSArbq5UITv+Q5E48MKoqV9DkC2IeEpmf6SBrxV4yzJFTJF333e hZ/psUG2QYQgDiTxSkEefFhBFlSI4nnveEU3Mx/RcIVMrxZPV4xkP7ODA/cifdmBSVaz 2rWw==
- In-reply-to: <firstname.lastname@example.org>
- List-help: <mailto:email@example.com>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:firstname.lastname@example.org>
- List-unsubscribe: <mailto:email@example.com>
- Mail-followup-to: Peter Stephenson <p.stephenson@xxxxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20180513212553.GA29028@chaz.gmail.com> <CAKc7PVDyrTMsmBSEDcMC=CNVCjOnEDVtywRYA0=UnNCBpF=7JQ@mail.gmail.com> <20180514063611.GA7263@chaz.gmail.com> <CGME20180514064505epcas3p1b2f178c595fc9bb962e4094e296ba699@epcas3p1.samsung.com> <20180514064431.GB7263@chaz.gmail.com> <firstname.lastname@example.org>
2018-05-14 09:47:33 +0100, Peter Stephenson:
> On Mon, 14 May 2018 07:44:31 +0100
> Stephane Chazelas <stephane.chazelas@xxxxxxxxx> wrote:
> > Tue Oct 13 21:42:47 1998 Andrew Main <zefram@xxxxxxx>
> > * Doc/Zsh/expn.yo, Src/glob.c: Add the [:blank:] character
> > class required by POSIX, which has no corresponding ctype macro.
> > Which explains why it's not using isblank() and strongly
> > suggests that it was not intentional.
> I think that's correct, but I tend to agree with Sebastian that some
> caution is required here since it's not necessarily clear what action
> with non-ASCII spaces is actually wanted when this is used. I'd be
> surprised if it actually broke anything, though.
I was going to say that surely, when someone uses [:blank:] that
means they want to trust the locale on the definition of
"blank", and I can't see why that should be different from other
character classes, but I just noticed that the documentation
The character is either space or tab
Instead of "horizontal whitespace". And on GNU systems,
"isblank(3)" also says its SPC and TAB:
Returns true if C is a blank character; that is, a space or a tab.
This function was originally a GNU extension, but was added in
While iswblank(3) is careful to refer to locale classification.
In practice, the only system where I could find a locale with a
single-byte charset with "blank" characters other than SPC and
TAB was NetBSD. And there, isblank(0xa0) under setlocale() in a
locale that uses ISO8859-1 for instance does return true (as
POSIX requires if that's how 0xa0 is classified in the locale.
However in the same locale, its sh (which is not multibyte
aware) outputs no in:
case $nbsb in
[[:blank:][:space:]]) echo yes;;
*) echo no
(bash outputs yes for both blank and space as POSIX requires).
I don't think many people complained when multi-byte support was
added and English people were starting to have their [[:alpha:]]
match on Greek or Korean letters in addition to English ones
(fair enough as "alpha" means the first letter of the Greek
The main problem if we want to align with other shells and make
the shell POSIX compliant is that the documentation currently
states explicitely that it matches on space and tab only.
The question is would any script be broken if we changed it?
People still keep using [a-z] when they mean to match English
lower case letters while in effect nowadays, except in zsh and a
very few other utilities that match ranges based on code points,
that matches on hundreds more (like à, œ, ć, if not ch, ﬁ...), I
wouldn't be surprised if people use [[:alnum:]] thinking it only
matches on Latin letters without diacritics and Arabic decimal
But then again, that still works more or less for them, as they
use it anyway against text that only contains English data.
To me the correct way to do a strict match against ASCII blanks
(or English letters, or ASCII punctuations) would be to use the
Messages sorted by: