From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15386 invoked by alias); 29 Jul 2011 01:40:32 -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: 16153 Received: (qmail 12039 invoked from network); 29 Jul 2011 01:40:21 -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=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.216.43 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=r36HAd9T5jcz4Oy1kB5alY4BucmPxaBnNlXnprZlvPE=; b=drL5qILPyRdC1yy8Sxs442gL240/Lwx7ZbTcYhJiaKSVGNzt114P2Wl48USu/bfj7s AM52KG9dHT0A9uv9r+YPshT2W8JriokZdvFcTGofidT8KolUuWRHJUlGHr3yP2BaQHQf i8B1psdkSUUc9gpGbq2ZGXHfh3x08UtOxI/vU= MIME-Version: 1.0 In-Reply-To: References: From: TJ Luoma Date: Thu, 28 Jul 2011 21:39:36 -0400 Message-ID: Subject: Re: how to refer to basename of $0 To: Zsh Users Content-Type: text/plain; charset=ISO-8859-1 Sorry folks, I'm explaining this really badly. Forget I said anything about bash. I don't care about bash. I'm trying to leave bash behind. Let me start over. Here's what happens in zsh 4.3.11 # my comments are offset with # # fyi - "Air%" is my prompt # just to show that $NAME is empty Air% echo $NAME Air% # /tmp/.source has only one line: Air% cat /tmp/.source NAME=`basename $0` # here is my 'test.zsh' script: Air% cat ./test.zsh #!/bin/zsh . /tmp/.source echo "$NAME" exit 0 # So now I run 'test.zsh' : Air% ./test.zsh .source # OK, so you can see that it output '.source' when I wanted it to output 'test.zsh' # Next: rename /tmp/.source to ~/.zshenv Air% mv /tmp/.source ~/.zshenv # Edited 'test.zsh' is now this: Air% cat =test.zsh #!/bin/zsh echo "$NAME" exit 0 #EOF # now when I run 'test.zsh' again: Air% test.zsh zsh # Someone suggested "unsetopt function_argzero" so I added that to .zshenv: Air% cat ~/.zshenv unsetopt function_argzero NAME=`basename $0` # and re-ran test.zsh, which gave me: zsh Is it even possible to set NAME in .zsh* (and have it return 'test.zsh' or are they called too early in the process? TjL