From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26323 invoked by alias); 29 Nov 2015 17:19:24 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 21008 Received: (qmail 27550 invoked from network); 29 Nov 2015 17:19:22 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1448817198; bh=fhvCg2HlGAT2cGv4r56Mij5jLUK7KhW1LlucbtGcI2g=; h=From:To:In-Reply-To:References:Subject:Date; b=OBxdVV+kTT0mGaXQ13VMI/Gi7hX7nHbHTDIL57dp59m71Ty3xpAzjHo6n8Zn5+YDt Wvlzbj+iS5zFLQ1F8hBaSRup2D7YPqPGUTb6cFs5ccYC8KfVL7TJ99/14eJUBxdqKA g/t3A++t5yzRlVdyXY+LqUpfeYXr49xEK7gel4j8= From: ZyX To: Ray Andrews , Zsh Users In-Reply-To: <565B18C6.6090707@eastlink.ca> References: <565B18C6.6090707@eastlink.ca> Subject: Re: lexing MIME-Version: 1.0 Message-Id: <970401448817197@web3h.yandex.ru> X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Sun, 29 Nov 2015 20:13:17 +0300 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=utf-8 29.11.2015, 18:26, "Ray Andrews" : > Gentlemen: > > The syntax highlighting in my editors makes the predictable mistake when > it bumps into these: > > (#b) > (#c1,2) > (#a3) > > because the lexing mostly follows bash rules. The people who write the > highlighter are interested in fixing that for zsh, but they want a > rigorous description of the rule. As far as I know the only rule there > is that if the hash is preceded by an open parenthesis then it is not a > comment. Is that sufficient or are there further subtleties? With `setopt extendedglob` `echo ech#test` errors with `zsh: no match`: AFAIR this is something like `*` in PCRE (and `##` is `+` in PCRE). With `unsetopt extendedglob` `echo ech#test` echoes `ech#test`, `interactivecomments` option is set in both cases. So the rule I think would be that `#` starts a comment if it is preceded by a whitespace. Also: 1. ${(kv#)var} 2. ${#var}: usual thing, also in POSIX shells 3. $#var 4. ${(s. # .)var} 5. $(( #var )) (usually causes Vim highlighting to fail) (also $[ #var ]) 6. ${var// # /test} 7. ${var//# /test} (hash means different thing here) 8. ${var%#}, ${var:-#}, etc (POSIX) 9. '#', "#", \# (POSIX, ways of escaping hash) Note that `posh -c 'echo foo#bar'` (also bash, dash, busybox and ksh) echoes `foo#bar`. So without `setopt extendedglob` this is not zsh-specific. So if they show a “predictable mistake” in this case as well then they are false regardless of the shell they write highlighting for.