From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 1f575dc9 for ; Sun, 12 Jan 2020 11:29:03 +0000 (UTC) Received: (qmail 10548 invoked by alias); 12 Jan 2020 11:28:56 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 45286 Received: (qmail 27158 invoked by uid 1010); 12 Jan 2020 11:28:56 -0000 X-Qmail-Scanner-Diagnostics: from blaine.gmane.org by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.1/25684. spamassassin: 3.4.2. Clear:RC:0(195.159.176.226):SA:0(0.3/5.0):. Processed in 3.623307 secs); 12 Jan 2020 11:28:56 -0000 X-Envelope-From: gcszd-zsh-workers@m.gmane.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at m.gmane.org does not designate permitted sender hosts) X-Injected-Via-Gmane: http://gmane.org/ To: zsh-workers@zsh.org From: Stephane Chazelas Subject: Re: Use of == in functions Date: Sun, 12 Jan 2020 11:21:55 +0000 Message-ID: <20200112112155.yr7mgfuvjguldr6v@chaz.gmail.com> References: <20200112100906.GA95942__47727.4053309642$1578823915$gmane$org@pooh.prefix.duckdns.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit User-Agent: NeoMutt/20180716 Content-Disposition: inline In-Reply-To: <20200112100906.GA95942__47727.4053309642$1578823915$gmane$org@pooh.prefix.duckdns.org> 2020-01-12 11:09:06 +0100, Kusalananda Kähäri: [...] > == within [[ ]] > = within [ ] > > ... just like in bash (but bash allows its built in test/[ utility to > understand == too) [...] zsh's [ builtin also supports == as an alias of = (like its [[ ]] construct also supports == as an alias of =), but in zsh, =cmd is an operator that expands to the path of the cmd command, $ echo =ls /usr/bin/ls so you would need: [ a '==' b ] (or disable the =cmd feature with set +o equals) if for some reason you wanted to use the non-standard == in place of =. Just like you need [ a '=~' regex ] for regex matching. And [ a '<' b ] to compare strings lexically as < is also a redirection operator. Now, as none of <, ==, =~ are standard [ operators (so sh compatibility is no longer a good reason to use the "[" command), you might as well use the ksh-style [[...]] construct which doesn't have this kind of issue: [[ a =~ b ]], [[ a < b ]], [[ a == b ]] are all fine (but then again, there's no need to double the =. == is an operator that is needed in languages where there's a need to disambiguate between assignment and equality comparison, but inside [[...]] (as opposed to ((...)) for instance), there's no assignment) -- Stephane