From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10431 invoked by alias); 16 Mar 2015 07:21:02 -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: 34715 Received: (qmail 28845 invoked from network); 16 Mar 2015 07:21:00 -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:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=78HZf7XkxTX4odrT08MEDcArdIj+hQdXsRBwuBLK9SM=; b=glMUTqc7dWCl2aHOSwv+lqAUox3lqm7H8a11kT/GzDJ35MTrH5TpWmxZgJAgiPgsnq rI8mxiODuPJnLRYPoBH7YjGn379eKhz8UQxSAItTfPTEyWkJUKnGkjtymiWZgqUb8G6t OxZw9rH6m4eSqru+tUhXPgoN5HR8LwqVGPrVAyIRgCXSxOMWhWrDMji0SKuWmUOX+ee2 K3IikF4omClPBREnwIR3R2yNAFiphnxpUycYCr7acfXV/GDuUcpq6+dOjWs9ArDKL8aK ikA4RLbQRgFsw0nOqqaq16heBmcyxq1ec4U0WDpBmDLhB4diFlAK/aiYoErdfAHU9lC/ wyBA== X-Gm-Message-State: ALoCoQlhMygSVa2PoUz/DxM/rsuRLP1CgWPAZNwXJ3aiB9B5gHX6MlImakOaHPcFvuq2VFeQUNRW X-Received: by 10.60.141.41 with SMTP id rl9mr46360188oeb.31.1426490458252; Mon, 16 Mar 2015 00:20:58 -0700 (PDT) From: Bart Schaefer Message-Id: <150316002055.ZM14534@torch.brasslantern.com> Date: Mon, 16 Mar 2015 00:20:55 -0700 In-Reply-To: <20150315183501.12dda876@ntlworld.com> Comments: In reply to Peter Stephenson "Re: Attempt to document aliasing more fully" (Mar 15, 6:35pm) References: <150314135406.ZM26021@torch.brasslantern.com> <20150315183501.12dda876@ntlworld.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Zsh hackers list Subject: Re: Attempt to document aliasing more fully MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Mar 15, 6:35pm, Peter Stephenson wrote: } Subject: Re: Attempt to document aliasing more fully } } On Sat, 14 Mar 2015 13:54:06 -0700 } Bart Schaefer wrote: } > though I still think that if included, those should (a) still exclude } > newline and (b) require "alias -g". } } I've got no very strong feelings about keeping the new feature since } it's been the way it has for decades and it only got noticed as a side } issue. However, the limitations above sound sane, since using "alias } -g" is already for hotheads, so maybe that's a good compromise. OK, no code changes yet, but here for consideration is the corresponding documentation change. The caveats necessary about "((" and "\&&" give me a nervous tic and re-emphasize why I think allowing this is loony. On the other hand we already have this problem with \$(echo foo) [which I think nobody would complain about *dropping* from the list of eligible words, but I've been wrong before]. diff --git a/Doc/Zsh/grammar.yo b/Doc/Zsh/grammar.yo index b30e423..e8e68ed 100644 --- a/Doc/Zsh/grammar.yo +++ b/Doc/Zsh/grammar.yo @@ -538,8 +538,7 @@ 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 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. +is always eligible for purposes of alias expansion. findex(alias, use of) cindex(aliases, global) An alias is defined using the tt(alias) builtin; global aliases @@ -555,22 +554,32 @@ 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.)) +itemiz(With global aliasing, any command separator, any redirection +operator, and `tt(LPAR())' or `tt(RPAR())' when not part of a glob pattern enditemize() -Reserved words are not eligible for aliasing when tt(POSIX_ALIASES) is set. -The tt(alias) builtin does not reject ineligible aliases, but they are not -expanded. +It is not presently possible to alias the `tt(LPAR()LPAR())' token that +introduces arithmetic expressions, because until a full statement has been +parsed, it cannot be distinguished from two consecutive `tt(LPAR())' +tokens introducing nested subshells. + +When tt(POSIX_ALIASES) is set, only plain strings or glob patterns are +eligible for aliasing. The tt(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 word, e.g. tt(\foo). Any form of quoting works, although there is nothing to prevent an alias being defined for the quoted form such as -tt(\foo) as well. For use with completion, which would remove an -initial backslash followed by a character that isn't special, it may be -more convenient to quote the word by starting with a single quote, -i.e. tt('foo); completion will automatically add the trailing single -quote. +tt(\foo) as well. Also, if a separator such as tt(&&) is aliased, +tt(\&&) turns into the two tokens tt(\&) and tt(&), each of which may +have been aliased separately. Similarly for tt(\<<), tt(\>|), etc. + +For use with completion, which would remove an initial backslash followed +by a character that isn't special, it may be more convenient to quote the +word by starting with a single quote, i.e. tt('foo); completion will +automatically add the trailing single quote. There is a commonly encountered problem with aliases illustrated by the following code: