Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Is this a bug, doc error, or misunderstanding?
- X-seq: zsh-users 16678
- From: Larry Schrof <larrys@xxxxxx>
- To: "zsh-users@xxxxxxx" <zsh-users@xxxxxxx>
- Subject: Re: Is this a bug, doc error, or misunderstanding?
- Date: Thu, 29 Dec 2011 23:11:12 +0000
- Accept-language: en-US
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : subject : date : message-id : in-reply-to : content-type : mime-version; s=facebook; bh=FqOph/0UFqGvzExcHs3lc+/CGAjPPORVQ0Fy1nMbea8=; b=gcxnFeAu05eqZA9SrzVBzWMj16OnoOQbfqsFwfQt00zG/LHKAox5/ht7Z+Oqaob8IG2c C5jT9WjWGHLwH/Dszd439WjEtYwjCi1C0LKvcXa7Z9HbQDb6OI0vnt+T55Co4cTG7rjY EWsAYda1Ry+MOWOr0n95S7V0qs6RoOsOhNU=
- In-reply-to: <CB222EBD.2F40%larrys@fb.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- Thread-index: AQHMxnxIGVTFm2hEIEOo6/jur/S2qpXzcVQA
- Thread-topic: Is this a bug, doc error, or misunderstanding?
I think I answered my own question after brainstorming with some co-workers.
I believe my locale is forcing sorting to be case-insensitive (This is hinted at
in the (o) expansion flag):
$ LANG=en_US.UTF-8
$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
$ VAR=(a b c X x Y y Z z)
echo ${(n)VAR}
a b c x X y Y z Z
$ LC_COLLATE=C
echo ${(n)VAR}
X Y Z a b c x y z
Looks like setting 'LC_COLLATE' helps solve my problem!
From: ls <larrys@xxxxxx<mailto:larrys@xxxxxx>>
Date: Thu, 29 Dec 2011 14:50:37 -0800
To: "zsh-users@xxxxxxx<mailto:zsh-users@xxxxxxx>" <zsh-users@xxxxxxx<mailto:zsh-users@xxxxxxx>>
Subject: Is this a bug, doc error, or misunderstanding?
From the zshexpn man page under 'Parameter Expansion Flags' section:
n Sort decimal integers numerically; if the first differing charac-
ters of two test strings are not digits, sorting is lexical.
Integers with more initial zeroes are sorted before those with
fewer or none. Hence the array ‘foo1 foo02 foo2 foo3 foo20 foo23’
is sorted into the order shown. May be combined with ‘i’ or ‘O’.
So that tells me that as two elements are being compared, and the sort hits the
first occurrence of two differing characters, AND those characters are not
digits, sort the entries lexiographically.
$ VAR=(ZHOST40 HOST+ host04 host4 host36)
I would expect this, using the (n) expansion flag, to sort to:
HOST+ ZHOST40 host04 host4 host36
This is because when comparing 'ZHOST40' and 'host04', 'Z' comes before 'h'
lexiographically. However, this is not what we get...
$ echo ${(n)VAR}
HOST+ host04 host4 host36 ZHOST40
It appears as if the (n) flag in this case applied an implicit case-insensitive
flag (i), which is not what I wanted.
Is this a bug in the (n) expansion flag, an erroneous explanation in the man page,
or just something fundamental thing I'm not getting?
Thanks!
P.S. Zsh version 4.3.10
Messages sorted by:
Reverse Date,
Date,
Thread,
Author