From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 17101 invoked from network); 23 Jun 2020 09:15:31 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 23 Jun 2020 09:15:31 -0000 Received: (qmail 12254 invoked by alias); 23 Jun 2020 09:15: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: List-Unsubscribe: Sender: zsh-users@zsh.org X-Seq: 24943 Received: (qmail 29312 invoked by uid 1010); 23 Jun 2020 09:15:24 -0000 X-Qmail-Scanner-Diagnostics: from smtpq2.tb.ukmail.iss.as9143.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.3/25850. spamassassin: 3.4.4. Clear:RC:0(212.54.57.97):SA:0(-2.7/5.0):. Processed in 1.828053 secs); 23 Jun 2020 09:15:24 -0000 X-Envelope-From: p.w.stephenson@ntlworld.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _mailcloud.virginmedia.com designates 212.54.57.97 as permitted sender) X-Env-Mailfrom: p.w.stephenson@ntlworld.com X-Env-Rcptto: zsh-users@zsh.org X-SourceIP: 172.25.160.154 X-CNFS-Analysis: v=2.3 cv=Lf2nFgXi c=1 sm=1 tr=0 a=0gQdd85zlVecdCXELxTKIw==:117 a=KEnZaF_ea6UA:10 a=IkcTkHD0fZMA:10 a=DoY9bV0jb9AA:10 a=pGLkceISAAAA:8 a=NE_dFHGx4HRt26RHoK4A:9 a=QEXdDO2ut3YA:10 X-Authenticated-Sender: p.w.stephenson@ntlworld.com Date: Tue, 23 Jun 2020 10:14:41 +0100 (BST) From: Peter Stephenson To: zsh-users@zsh.org Message-ID: <1729280279.18645.1592903681952@mail2.virginmedia.com> In-Reply-To: <20200623083703.GA13538@pooh.prefix.duckdns.org> References: <20200623083703.GA13538@pooh.prefix.duckdns.org> Subject: Re: Alias call in function fails... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Priority: 3 Importance: Medium X-Mailer: Open-Xchange Mailer v7.8.4-Rev70 X-Originating-IP: 165.225.81.56 X-Originating-Client: open-xchange-appsuite X-CMAE-Envelope: MS4wfEUbD5SZZiKLFbZWo0kldbNw1JEZ1JHeilMWfAJcGmb1DLSysL7Ky5tvlJPbCR1jGiSVxBFSr2zod34WpONy1W/6wYfhbNRIydvGeQlm5+ea+qqmrnOI NSTg718wWPz0moWVONkP6ub6XpbGZaGsQgX9xYsIwLzjHapQju2zfSNr/JNI/6gr1v81b/WvG0f21vaGFjnqRdU8RpsLSb6cJZw= > On 23 June 2020 at 09:37 Andreas Kusalananda K=C3=A4h=C3=A4ri wrote: > On Tue, Jun 23, 2020 at 01:23:55AM +0200, Mikael Magnusson wrote: >> On 6/22/20, Frank Gallacher wrote: >>> Greetings, >>> >>> I have a function: >>> >> [...] >>> >>> Which calls an alias: >>> >>> alias dumpit=3D'hexdump -C -n 128' >>> >>> It works fine in bash, but with zsh now I get: >>> >>> :::::::: test.txt :::::::: >>> dumpall:11: command not found: dumpit >>> >>> Am I doing something wrong??? >>=20 >> Aliases are expanded on parse time, which means aliases defined in a >> file won't be usable in that same file. (Because it is parsed in its >> entirety before any of the code is actually run). >=20 > If the alias is defined before the definition of the function, it ought t= o work. It's a bit more complicated than that. There's a difference between a file that's being executed line by line, which includes initialisation files and sourced files as well as scripts, and a file that's parsed and then exe= cuted, which would include an autoloaded function definition. In the former case, the alias is defined before the function definition is executed; in the lat= ter case it isn't, even though the line with the alias definitions appears befo= re the function definition. For sure you can't define the alias *after* the function definition. pws