zsh-workers
 help / color / mirror / code / Atom feed
From: ZyX <kp-pav@yandex.ru>
To: Eric Cook <llua@gmx.com>, "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: [[ is being treated as a pattern in the command/reserved word position.
Date: Sun, 29 Mar 2015 02:19:28 +0300	[thread overview]
Message-ID: <6544501427584768@web10m.yandex.ru> (raw)
In-Reply-To: <55173419.6070103@gmx.com>

29.03.2015, 02:07, "Eric Cook" <llua@gmx.com>:
> On 03/28/2015 06:33 PM, ZyX wrote:
>>  29.03.2015, 01:25, "Bart Schaefer" <schaefer@brasslantern.com>:
>>>  On Mar 28,  5:55pm, Eric Cook wrote:
>>>  }
>>>  } % print $ZSH_PATCHLEVEL; emulate sh -c '[[ a == a ]]'
>>>  } zsh-5.0.7-362-gab40656
>>>  } zsh: command not found: [[
>>>  }
>>>  } Did that behavior change?
>>>
>>>  Aha.  That makes more sense.
>>>
>>>  The '[[' reserved word is handled a special kind of built-in alias [*]
>>>  and the change to POSIX_ALIASES handling caused that to be disabled.
>>>
>>>  This will take a bit of thought.
>>>
>>>  [*] Not literally, but the alias expansion code is where '[[' is noted
>>>  and the lexer changed into "parsing a conditional" state.
>>  I would say that this is actually an expected behaviour: `posh -c '[[ a == a ]]'` will show `posh: [[: not found` because `[[` is not in POSIX. Similar error will be shown by dash.
>
> Nor is it disallowed by POSIXand it used to work, the bug report is
> still valid.

`[[` 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.


  reply	other threads:[~2015-03-28 23:25 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-28 21:08 Eric Cook
2015-03-28 21:18 ` Eric Cook
2015-03-28 21:25 ` Eric Cook
2015-03-28 21:36 ` ZyX
2015-03-28 21:44 ` Bart Schaefer
2015-03-28 21:55   ` Eric Cook
2015-03-28 22:24     ` Bart Schaefer
2015-03-28 22:33       ` ZyX
2015-03-28 22:45         ` Bart Schaefer
2015-03-28 23:07         ` Eric Cook
2015-03-28 23:19           ` ZyX [this message]
2015-03-28 23:27             ` Eric Cook
2015-03-28 23:57               ` ZyX
2015-03-29  0:09                 ` Eric Cook
2015-03-28 22:44       ` Peter Stephenson
2015-03-28 22:48         ` Bart Schaefer

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=6544501427584768@web10m.yandex.ru \
    --to=kp-pav@yandex.ru \
    --cc=llua@gmx.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).