From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29270 invoked by alias); 29 Nov 2015 18:07:19 -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: 21009 Received: (qmail 7889 invoked from network); 29 Nov 2015 18:07:16 -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,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version:content-type; bh=6l/qi1zY380rwTaTit9gC7ObXOP44qZKFbwoUmotsgE=; b=F2qewB42ohJltO0C75w07zncqwC9hgmPS1DMYZKrEcYKpx24PvvvxHQ/NonvO+Fbdc 8AcWZRV7Nr5Q4rP1qEfwFSDYqRVza7Kvrt7pFzYaCmU0Bk/YSRUMBd67K2O7OyOwKrWi sr7VO4TK4BPLwyfOePGe35O7dylDB6UCdOmOhoWTd1ZMHV6Wo74q7xhC+t1EOgfuVAiJ rBLrQJoYySuMoKu6vNlo0bLwbygiuSNfOwQTiD1Cxou+mHxi3eL6x7jM2zOgstaehFEb wUpgm0mETU1tWYc1Pt5onHDb+osy3cdJiK8qxqflyIst5UYp3L5WbPQn2uR01vxN9djO +oDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=6l/qi1zY380rwTaTit9gC7ObXOP44qZKFbwoUmotsgE=; b=bwv+EzACrEsq2hpXy//kCU3lBVMhlEE2HHKiGMoH5kh3vl6vnmknjxOaikFGjhJyrD MWTfqHzKwrU0ugzoRR17ONzBOSkFbuPqQYcHtVgt/wO3JVjSCr/kFSXlur579GJb/y8u VWBzKRFSRczLx9Sq3Uftc4buBsIjezEzbXAYaEgqoHTmgRBz8evjpcablWDDu8w6vtPO 8jWfl/5z5aQYiNdZ7iL4KNG279vIAiRzBWQ+5BPzPwqVAI2xZA2c8Pw39QSgK7uMWKro FxRusz/cc34KXetsccOV5b5CbyT516K5w+hBpwP/R+7YF7M2p7+nqghd35g0dq1b3FFx GWfA== X-Gm-Message-State: ALoCoQkKgXKXd2Iv23UHcLM5MbnnsF2ERBjyahZxheo6SEuOljTIKB2VQhES7BpabHXrlkk7SJUN X-Received: by 10.98.86.132 with SMTP id h4mr64824904pfj.121.1448820433904; Sun, 29 Nov 2015 10:07:13 -0800 (PST) From: Bart Schaefer Message-Id: <151129100735.ZM24525@torch.brasslantern.com> Date: Sun, 29 Nov 2015 10:07:35 -0800 In-Reply-To: <565B18C6.6090707@eastlink.ca> Comments: In reply to Ray Andrews "lexing" (Nov 29, 7:24am) References: <565B18C6.6090707@eastlink.ca> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Zsh Users Subject: Re: lexing MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Nov 29, 7:24am, Ray Andrews wrote: } } 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? I'll leave the following analysis of all the places where a "#" is NOT a comment, because I went to the trouble of writing it all down, after which I realized it's a whole lot easier to explain: The # character introduces a comment ONLY when it is immediately preceded by a command terminator (including start of line) or by whitespace that acts as a word separator. Everywhere else, # is NOT a comment, in contexts such as: $# is the obvious one, but they probably have that covered. Also any "#" that appears inside ${...} should not be treated as a comment, except that inside $(...) the normal comment rules apply even if that is also inside ${...}. (Aside to zsh-workers: $(...) is apparently NOT "interactive" even if typed at the command line, for INTERACTIVE_COMMENTS purposes.) In arithmetic expressions, digits followed by "#" are the base of the number, e.g., 2#111 is 10#7. Also open-bracket followed by "#" and then digits and close-bracket specifies an output base, e.g. $[[#2]7] substitutes 2#111 -- I'm deliberately using the $[...] alternative to $(( [#2] 7 )) and squashing spaces). Oh, and [#10_3] means output base 10 with underscores between every group of 3 digits, and [##8] means output in octal with no 8# prefix (works for any base). Then (still in math context) there's ##Z which outputs the value of the character Z, which can also be a sequence e.g. $(( ##\e )) is 27, and (( #VAR )) is the same as ## except on the first character in the value of $VAR. The form you're using (#something), is only not-a-comment in pattern or filename-generation context, so $(# this IS a comment). And of course once you have started a (#...) that is not a comment, any # that is before the closing paren is also not a comment. Lastly there's # and ## at the end of any string in pattern or name- generation context, which is never a comment even if extended_glob is not set. Final note: The one thing zsh borrowed from csh that I freely concede is pretty horrible, is the ability to change the comment character by changing the third character of $histchars. Please never do this.