Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] Use == in expressions instead of the deprecated =
- X-seq: zsh-workers 39251
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- Subject: Re: [PATCH] Use == in expressions instead of the deprecated =
- Date: Thu, 8 Sep 2016 15:31:28 +0100
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=04iLO4y91R2PCRxKa4eBHKrBGvvxeyh1oF4hmgiRfmU=; b=bI1DBsyWCmkxzfcpXmc21iPZqeF+WJrD4pdx7JswKEPjf5nzBUVkqukavpwNDi9qSs I4pbxwelKsuzXvMUBfGYRLRnQIjB22R0QfjWI85B4XokDKNRlXtWnXKg9KXOgju3kH5L ZWMp/VwiaiyreCZVQKscXgi9zUB4FOPDHXNDTpLnKNgjABkXQL/0qrl2kEMdExxjbNUi /cBSCnS3l/k9YUVKH4WihirJvzyqPA2g1VPSjwq/a1Yur3gNNfQi6W4Lk57P1Pt7Ih+q XKuZYoNCLq3Xb5Q6fiweqvaKsSgmc6Zgf2KNYzRJuMsP7SGEy2bd5nGYM95DQySj9Kxp xVNw==
- In-reply-to: <20160908121628.78977edd@pwslap01u.europe.root.pri>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mail-followup-to: Peter Stephenson <p.stephenson@xxxxxxxxxxx>, zsh-workers@xxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20160905212754.24998-1-tgyurci@gmail.com> <20160908093516.4fc2dd1e@pwslap01u.europe.root.pri> <20160908121628.78977edd@pwslap01u.europe.root.pri>
2016-09-08 12:16:28 +0100, Peter Stephenson:
[...]
> diff --git a/Doc/Zsh/cond.yo b/Doc/Zsh/cond.yo
> index 3d369fb..6fcf3bd 100644
> --- a/Doc/Zsh/cond.yo
> +++ b/Doc/Zsh/cond.yo
> @@ -103,8 +103,8 @@ true if var(file1) and var(file2) exist and refer to the same file.
> xitem(var(string) tt(=) var(pattern))
> item(var(string) tt(==) var(pattern))(
> true if var(string) matches var(pattern).
> -The `tt(==)' form is the preferred one. The `tt(=)' form is for
> -backward compatibility and should be considered obsolete.
> +The `tt(==)' form is the preferred one for clarity in new shell code
> +as it more closely resembles other languages.
[...]
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).
I suspect the reason David Korn obsoleted "==" is mainly for
consistency with the ((...)) "==" operator. There, "==" is
comparison and "=" is assignment like in C/awk (and other
languages that don't do the disambiguation via some other mean
like :=/= or <-/=).
However inside [[...]], there is no possible confusion between
assignment and comparison as [[...]] is only a construct for
doing tests, so no point in having a "==" there.
I personally use "=" (even for [[...]]), as that's what's
standard for "test"/"[".
The risk with stating that "==" is obsolete is that people are
going to start using [ "$a" == "$b" ] (as many do already)
thinking it's the right thing to do and get bitten when "sh"
changes from bash/zsh/ksh/yash to another sh implementation
whose "test" builtin doesn't support "=="
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author