From: Stephane Chazelas <stephane.chazelas@gmail.com>
To: Peter Stephenson <p.stephenson@samsung.com>, zsh-workers@zsh.org
Subject: Re: [PATCH] Use == in expressions instead of the deprecated =
Date: Thu, 8 Sep 2016 16:06:32 +0100 [thread overview]
Message-ID: <20160908150632.GA15106@chaz.gmail.com> (raw)
In-Reply-To: <20160908143128.GA14933@chaz.gmail.com>
2016-09-08 15:31:28 +0100, Stephane Chazelas:
[...]
> ksh93 also makes "==" obsolete in [[...]]. "==" is still not
> POSIX (and likely not going to be soon as requests to add it
> have been rejected (IIRC)) for the "test"/"[" utility (or expr).
[...]
Appart from bash 2.02, I don't know of a shell implementation
that treats [[ = ]] differently from [[ == ]] (or [ = ] vs [ ==
] for those "[" implementations that support ==) however note
that yash has a 3rd operator: [ === ] that is short for [ '<=' ]
&& [ '>=' ] or [ ! '<' ] && [ ! '>' ].
As in yash like in bash or ksh93 (but not zsh), < and > for
string comparison use strcoll() (like sort/expr or awk's </> for
strings) while == uses strcmp. And in some locales, there are
strings that sort the same even though they are different.
yash's === is a test to check that two strings sort the same,
like the "=" operator of expr (or the == operator of some awk
implementations as currently required by POSIX (though that's
going to change)).
For instance in a en_GB.UTF-8 locale on a GNU system, \u2461
sorts the same as \u2462 (in that case, a bug).
expr $'\u2461' = $'\u2462'
and
yash -c '[ \u2461 === \u2462 ]'
return true while
[[ \u2461 < \u2462 ]] and [[ \u2461 > \u2462 ]]
both return false in bash and ksh93.
zsh's behaviour is more consistent here but means that for
instance
[[ Stéphane < Stuff ]]
returns false (while bash and ksh93 return true) even though
I'd exect é to sort before u.
See also
https://unix.stackexchange.com/questions/56655/what-is-the-difference-between-a-z-and-a-z/56674#56674
--
Stephane
next prev parent reply other threads:[~2016-09-11 2:30 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-05 21:27 Teubel György
2016-09-08 8:35 ` Peter Stephenson
2016-09-08 11:16 ` Peter Stephenson
2016-09-08 14:31 ` Stephane Chazelas
2016-09-08 15:06 ` Stephane Chazelas [this message]
2016-09-08 15:14 ` Peter Stephenson
2016-09-08 16:39 ` Mikael Magnusson
2016-09-08 18:47 ` Stephane Chazelas
2016-09-09 12:03 ` Vincent Lefevre
[not found] ` <CGME20160912143133eucas1p11a4e6916dd70b3ceaa163bf3bddfb007@eucas1p1.samsung.com>
2016-09-12 14:31 ` Peter Stephenson
2016-09-09 8:52 ` Stephane Chazelas
2016-09-09 9:31 ` Peter Stephenson
2016-09-09 16:00 ` Stephane Chazelas
2016-09-14 22:01 ` PATCH: [[ -v varname ]] Oliver Kiddle
2016-09-15 10:55 ` Vincent Lefevre
2016-09-16 0:36 ` Bart Schaefer
2016-09-15 11:08 ` Stephane Chazelas
2016-09-15 11:22 ` wrong "export -p" output for exported but not set variables (Was: PATCH: [[ -v varname ]]) Stephane Chazelas
2016-09-09 17:01 ` [PATCH] Use == in expressions instead of the deprecated = Christian Neukirchen
2016-09-09 18:54 ` Stephane Chazelas
2016-09-09 13:05 ` Peter Stephenson
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=20160908150632.GA15106@chaz.gmail.com \
--to=stephane.chazelas@gmail.com \
--cc=p.stephenson@samsung.com \
--cc=zsh-workers@zsh.org \
/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).