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=DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 28007 invoked from network); 7 Jul 2020 20:29:12 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 7 Jul 2020 20:29:12 -0000 Received: (qmail 16226 invoked by alias); 7 Jul 2020 20:29:04 -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: List-Unsubscribe: Sender: zsh-workers@zsh.org X-Seq: 46210 Received: (qmail 7137 invoked by uid 1010); 7 Jul 2020 20:29:04 -0000 X-Qmail-Scanner-Diagnostics: from mail-io1-f51.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.3/25863. spamassassin: 3.4.4. Clear:RC:0(209.85.166.51):SA:0(-2.0/5.0):. Processed in 6.014367 secs); 07 Jul 2020 20:29:04 -0000 X-Envelope-From: mikachu@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.166.51 as permitted sender) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=DPBmNC7TXOhy9J3hyy6kyG5C5RG1FiC8bz0WoBcch+g=; b=GjQLc9t3eZ+g2ryrSrPLIC3agtW1nL15TbN0mjsMxHXn46GuS7xPT/fCjoaEmg177p x2f5rq9oJGVTiEUtqGsMpA0MtPzqZfBiRAHOx2fNSPex2eestoGc6YfaKkcO1ZQcC+rE qEVchMX3iveNtXsMd9+IKogx25jAfhU66IUUJXG7Hp3iDOD9DRgw+ylDaRckCyd3qzHN XUn5YPfjGPBekBGWoZl217fhqMvSo7gvJ0JbwnUWeTifNmaky87Ng7DrmUIvxyoeqEsw 6Adj8q9GS/7ZQugDEodNK5oAsaWv+3SJoiewA7KEIa32opTfDbPrwm6r/GhsCZjSRLzv v7lQ== X-Gm-Message-State: AOAM533GOQHU93tvw7XeF/T3ijb0tWHWNo1PJepjzv1wJWchC1blN1jM aYTaxEYE55tairsjEu2F8OzHPLN5IwAVIsrEd9Q= X-Google-Smtp-Source: ABdhPJxpnnVJa6UCVFT0Ac+c/7gsGUld4gUu4JTuYvnsxQrdVTxHaQ5oFBXI44SJBsQ21JnKR563wbROfojQWqeWa4s= X-Received: by 2002:a6b:b457:: with SMTP id d84mr33083496iof.21.1594153705456; Tue, 07 Jul 2020 13:28:25 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Mikael Magnusson Date: Tue, 7 Jul 2020 22:28:24 +0200 Message-ID: Subject: Re: zcompile does not expand aliases defined in the compiled script To: Roman Perepelitsa Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" On 7/7/20, Roman Perepelitsa wrote: > I naively expected that `zcompile x && source x` has the same effect > as plain `source x` but apparently when using the former aliases > defined within `x` aren't expanded during the evaluation of `x`. > > Is this expected behavior? > > % zsh -f > % print 'alias x=:; x' >x > % zcompile x > % source x > x:1: command not found: x It is expected, but you are not correct that it works when you didn't compile the file first: % source x zsh: command not found: x However, sourcing a non-compiled file multiple times will of course work on subsequent runs because the alias is carried across in the shell session. If you zcompile the file after sourcing it once, it will also work subsequently (even in new sessions) as aliases, if any, are expanded at compile time (unless inhibited by -U). It is possible that you changed the example in the mail without trying what you changed; if you have the statements alias x=: x in the file x, then sourcing it (non-compiled) will work, since it is parsed and executed line by line. This does not change anything for the zcompile case from the above paragraph as the entire file is parsed and nothing is executed. Hopefully all of the above is true, I did my best to test it :). -- Mikael Magnusson