From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19557 invoked by alias); 29 Mar 2015 00:03:25 -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: X-Seq: 34810 Received: (qmail 23255 invoked from network); 29 Mar 2015 00:03:23 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,T_FSL_HELO_BARE_IP_2 autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1427587061; bh=3ivsaJpfOpcmg/+FjTq37Q42zMaCLXVzBfmJoQa/xHI=; h=From:To:In-Reply-To:References:Subject:Date; b=T6nQdUNdV8vXSBaYr/Z3nGCak66UzUW/iWQuo0XkZEX0JKzgWJi0rq598cUrReLaz O6HKPuXFHgnzLT0+eP3/RZUM/CIaa5aafejkt6w4tcAQFkgApJp4tmGy132SX2nhTM lOP98/JBs69VoLV7H87EDfYnLX/PC9IZmBkQBRxg= From: ZyX To: Eric Cook , "zsh-workers@zsh.org" In-Reply-To: <551738D8.805@gmx.com> References: <55171842.7030505@gmx.com> <150328144428.ZM5583@torch.brasslantern.com> <55172355.80409@gmx.com> <150328152430.ZM18574@torch.brasslantern.com> <6862591427582011@web25h.yandex.ru> <55173419.6070103@gmx.com> <6544501427584768@web10m.yandex.ru> <551738D8.805@gmx.com> Subject: Re: [[ is being treated as a pattern in the command/reserved word position. MIME-Version: 1.0 Message-Id: <5441381427587060@web10j.yandex.ru> X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Sun, 29 Mar 2015 02:57:40 +0300 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=utf-8 29.03.2015, 02:27, "Eric Cook" : > On 03/28/2015 07:19 PM, ZyX wrote: >>  29.03.2015, 02:07, "Eric Cook" >>  `[[` is a *syntax extension*. This *is* going against POSIX. If `[[` in POSIX emulation mode was implemented as a shell built-in in a manner that allows implementing it as a script your concern would be valid. But implementing `[[` as a shell built-in is breaking certain expectations about how `[[` is supposed to work. >> >>  Specifically, with >> >>      setopt SH_WORD_SPLIT >>      w="a = b" >>      test $w # False: a ≠ b, expected >>      [[ a = b ]] # False: a ≠ b, expected >>      [[ $w ]] # True: w is not empty, should be false if shell is POSIX >> >>  . It is easier to disable `[[` then keep two implementations of it. > > See 2.4 of: > http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html >>  The following words may be recognized as reserved words on some > > implementations (when none of the characters are quoted), causing > unspecified results: >>  [[ ]]functionselect There is a bit of problem: http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_05 (Field Splitting) section does not talk about any exceptions for the field splitting. There is only one official exception to this rule: function definition. I cannot say whether “uspecified result” makes current behaviour of `[[` (non-)conformant. There is also another consideration: POSIX does not define `[[`. So when you run an emulation mode *what exactly* should `[[` do? When emulating `bash` (not present for some reason) or `ksh` this is defined by those shells, but `sh` is clearly not a bash emulation (reasoning: BASH_REMATCH is not set) and not ksh emulation (reasoning: `emulate ksh` is a distinct emulation mode and `sh` emulation mode is not referenced as an alias of `ksh` emulation mode). I have failed to find what zsh developers meant by `sh` emulation exactly though: it is not explicitly said that it emulates POSIX shell. But since it not bash or ksh emulation mode `[[ $w ]]` in the above case should be `false` (busybox emulation) or a command-not-found error (posh or dash emulation).