Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [[ is being treated as a pattern in the command/reserved word position.



On 03/28/2015 07:19 PM, ZyX wrote:
> 29.03.2015, 02:07, "Eric Cook" <llua@xxxxxxx>
> `[[` 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



Messages sorted by: Reverse Date, Date, Thread, Author