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 13372 invoked from network); 23 Jun 2020 08:37:57 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 23 Jun 2020 08:37:57 -0000 Received: (qmail 22301 invoked by alias); 23 Jun 2020 08:37:46 -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: 24942 Received: (qmail 801 invoked by uid 1010); 23 Jun 2020 08:37:46 -0000 X-Qmail-Scanner-Diagnostics: from hekla.abc.se 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(158.174.61.227):SA:0(-1.9/5.0):. Processed in 3.168507 secs); 23 Jun 2020 08:37:46 -0000 X-Envelope-From: andreas.kahari@abc.se X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at abc.se designates 158.174.61.227 as permitted sender) Date: Tue, 23 Jun 2020 10:37:03 +0200 From: Andreas Kusalananda =?utf-8?B?S8OkaMOkcmk=?= To: Mikael Magnusson Cc: Frank Gallacher , "zsh-users@zsh.org" Subject: Re: Alias call in function fails... Message-ID: <20200623083703.GA13538@pooh.prefix.duckdns.org> Mail-Followup-To: Mikael Magnusson , Frank Gallacher , "zsh-users@zsh.org" References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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='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??? > > Yes, don't use aliases for anything but interactive usage. Eg if you > want to use dumpit in a script, make it be a function: > dumpit() { hexdump -C -n 128 } > > 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). > > -- > Mikael Magnusson If the alias is defined before the definition of the function, it ought to work. -- Andreas (Kusalananda) Kähäri SciLifeLab, NBIS, ICM Uppsala University, Sweden .