From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 528 invoked by alias); 29 Jul 2011 22:31:12 -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: X-Seq: 16161 Received: (qmail 10204 invoked from network); 29 Jul 2011 22:31:01 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <110729153042.ZM25377@torch.brasslantern.com> Date: Fri, 29 Jul 2011 15:30:42 -0700 In-reply-to: Comments: In reply to "Benjamin R. Haskell" "Re: how to refer to basename of $0" (Jul 29, 10:08am) References: <110728210438.ZM24370@torch.brasslantern.com> <1311940087.1494.27.camel@localhost.localdomain> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: how to refer to basename of $0 MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Jul 29, 10:08am, Benjamin R. Haskell wrote: } Subject: Re: how to refer to basename of $0 } } On Fri, 29 Jul 2011, Tomasz Moskal wrote: } } > On Thu, 2011-07-28 at 21:04 -0700, Bart Schaefer wrote: } >> On Jul 28, 9:39pm, TJ Luoma wrote: } >> } } >> } Is it even possible to set NAME in .zsh* (and have it return } >> } 'test.zsh' or are they called too early in the process? } >> } >> This is sounding awfully familiar. Oh, it was on zsh-workers, where } >> some of the -users crowd would not have seen it. } > } > Thanks for the links, but I am still baffled - basename $0 is } > working here without any problems: } } The point wasn't quite the same (didn't involve "source"-ing .zshenv). } $0 doesn't work if used inside startup files (.zshenv/.zshrc/.zprofile). } When you source it manually, it's not treated specially. } } Just wanted to note that the '%x' that I pointed out does work, though: } } ## as the first line of .zshenv (so, will be run when starting zsh) } $ sed 1q ~/.zshenv } echo in .zshenv 0=$0 %x=${(%):-%x} And I just wanted to point out that ${(%):-%x} doesn't solve the problem being discussed in the zsh-workers thread I referenced; in the workers thread the desire is to find the name of the calling script, which has not yet been assigned to $0 at the time .zshenv is read. This led to the patch proposed here: http://www.zsh.org/mla/workers/2011/msg00180.html -- which has not yet been applied, the discussion having broken off at this point: http://www.zsh.org/mla/workers/2011/msg00183.html