From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17878 invoked by alias); 8 Apr 2018 20:54:37 -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: List-Unsubscribe: X-Seq: 23323 Received: (qmail 24658 invoked by uid 1010); 8 Apr 2018 20:54:37 -0000 X-Qmail-Scanner-Diagnostics: from mta01.eastlink.ca by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(24.224.136.30):SA:0(-2.6/5.0):. Processed in 2.787514 secs); 08 Apr 2018 20:54:37 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) 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, SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: rayandrews@eastlink.ca X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | MIME-version: 1.0 Content-transfer-encoding: 8BIT Content-type: text/plain; charset=utf-8; format=flowed X-Authority-Analysis: v=2.3 cv=IOss9DnG c=1 sm=1 tr=0 a=RnRVsdTsRxS/hkU0yKjOWA==:117 a=RnRVsdTsRxS/hkU0yKjOWA==:17 a=IkcTkHD0fZMA:10 a=OXmQ1zP-WOZvgot5pKIA:9 a=QEXdDO2ut3YA:10 X-EL-IP-NOAUTH: 24.207.101.9 Subject: Re: activate alias inside subshell To: zsh-users@zsh.org References: <604319cb-d86f-686b-ac9b-00d21650edff@eastlink.ca> <637434d9-ff23-53d4-5d31-443942fc2ef9@eastlink.ca> <180408131814.ZM7928@torch.brasslantern.com> From: Ray Andrews Message-id: <4ad264be-0d8f-e50e-e664-f6d118182caf@eastlink.ca> Date: Sun, 8 Apr 2018 13:54:29 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 In-reply-to: <180408131814.ZM7928@torch.brasslantern.com> Content-language: en-CA On 08/04/18 01:18 PM, Bart Schaefer wrote: > On Apr 8, 7:56am, Ray Andrews wrote: > } > } Is 'zsh -f' the answer to the above -- a truly clean test of something? > > The first thing asked following most bug reports is "can you reproduce > this from zsh -f?" So yes. Start from -f and then load the minimum > number of changes to try what you want to try (e.g., add extendedglob > if necessary, zmodload zsh/parameter or other required modules, etc.). Thanks, I hate wasting everyone's time over really elementary issues like that. > } ... are very different! In the former the alias is 'pending' in the > } latter, it is active, yes? That's easy not to know. > > Yes, that's correct. "alias" is really intended only to make interactive > shells easier (reduce typing), not to abbreviate scripts (even if the > script is going to be used interactively later). I've always distrusted any sort of macro and I use aliases only in the most limited way possible.  The anomaly is with that 'print function and line' code which seems to be impossible to put inside a function via another function except via an alias IF you want to be able to turn it on and off, thus the can of worms is opened and after that it becomes a matter more of education.  I do understand that  " ${(%):-%x %I} " is a parse time thing which is why that string can't be in a function called by another function and report anything other than its position in the immediate function, so the alias seems inevitable.   If there was such a thing as a runtime expansion of an alias, sorta an automatic 'eval',  that would be cool but I can believe that such a thing is just not on. > > } BTW, results are hugely different if the redefined message function is > } redefined with or without 'function' prepended: " function msg () ... " > } vs. " msg () ... ". Most comments found on the internet suggest there > } should be no difference > > There's no difference when "msg" is not an alias. But in > msg() ... > the word "msg" is in command position and therefore subject to alias > expansion, whereas in > function msg () ... > it is *not* in command position and will not be alias-expanded. > Ah!!  Nuts ... I'm unconsciously thinking that a function definition is somehow immune to alias substitution.  Why would it be?  And yes, the 'command position' thing is easy to forget about.  I know it in theory but in practice ... Ok, I'll bet that's everything I need to understand my issue.