From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20599 invoked by alias); 14 Mar 2015 20:54:16 -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: 34712 Received: (qmail 12552 invoked from network); 14 Mar 2015 20:54:14 -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.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 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:to:subject:mime-version :content-type; bh=hbnLmiD1qtiZmWsl0oEJtDwhRjinQpofY1l2psjQaJk=; b=aqN8ne10kIh3GzBy87B7kgTayiRk3634Mr+q9uAVPLO3gsQJL4ka68GpoDJQ2+5sC2 3l1StqsA8CgW44+9om7Alzw+GI1ANQrWCxGKK7yboC0nfhOWn1Yl+NBJKsV8d8EmJ1MA l2Ui6ex0F7tsgBxgQndk1WUA0LgvM219AychKxOOk/eOgSlRLXxlgPyIyOCdIPcnA4ac FinHHj/vTwwb1xPUXWoBCmTKR++9VsNC92wPj2xRUzUi9yRXfz3wWDkuoVPZStdxRUNE IxJqEgl/TB2ahSH9RnHLne3G/R2a9fA0wHdPBly8yeDXEIP9Ey8oAPwjvvI4gAqDSptk MMMQ== X-Gm-Message-State: ALoCoQl4AMHqoaQSknlkilIf7BGfs8AKGwTvI8b6E9pCmvrdCR5uGBEXcz2MPc5olSTMhtt2Ujn3 X-Received: by 10.182.19.167 with SMTP id g7mr42406999obe.75.1426366449858; Sat, 14 Mar 2015 13:54:09 -0700 (PDT) From: Bart Schaefer Message-Id: <150314135406.ZM26021@torch.brasslantern.com> Date: Sat, 14 Mar 2015 13:54:06 -0700 X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Attempt to document aliasing more fully MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii So here is what I have (see diff below). This describes the situation prior to workers/34641. To keep 34641, we'd just have to add another itemiz() calling out command separators as a separate class of "word", though I still think that if included, those should (a) still exclude newline and (b) require "alias -g". Either way I rather suspect that POSIX_ALIASES should prohibit more than just the reserved words, e.g., I doubt that parameter references and quoted strings are meant to be allowed in aliases by POSIX. That should get fixed, along with the bug(s) mentioned in 34668 and 34682. diff --git a/Doc/Zsh/grammar.yo b/Doc/Zsh/grammar.yo index 63d90df..ee44841 100644 --- a/Doc/Zsh/grammar.yo +++ b/Doc/Zsh/grammar.yo @@ -532,12 +532,12 @@ characters up to a newline to be ignored. texinode(Aliasing)(Quoting)(Comments)(Shell Grammar) sect(Aliasing) cindex(aliasing) -Every token in the shell input is checked to see if there +Every eligible em(word) in the shell input is checked to see if there is an alias defined for it. If so, it is replaced by the text of the alias if it is in command position (if it could be the first word of a simple command), or if the alias is global. -If the text ends with a space, the next word in the shell input +If the replacement text ends with a space, the next word in the shell input is treated as though it were in command position for purposes of alias expansion. findex(alias, use of) @@ -545,6 +545,22 @@ cindex(aliases, global) An alias is defined using the tt(alias) builtin; global aliases may be defined using the tt(-g) option to that builtin. +A em(word) is defined as: + +startitemize() +itemiz(Any plain string or glob pattern) +itemiz(Any quoted string, using any quoting method (note that the quotes +must be part of the alias definition for this to be eligible)) +itemiz(Any parameter reference or command substitution) +itemiz(Any series of the foregoing, concatenated without whitespace or +other tokens between them) +itemiz(Any reserved word (tt(case), tt(do), tt(else), etc.)) +enditemize() + +Reserved words are not eligible for aliasing when tt(POSIX_ALIASES) set. +The alias builtin does not reject ineligible aliases, but they are not +expanded. + Alias expansion is done on the shell input before any other expansion except history expansion. Therefore, if an alias is defined for the word tt(foo), alias expansion may be avoided by quoting part of the