Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: how to refer to basename of $0
- X-seq: zsh-users 16153
- From: TJ Luoma <luomat@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: how to refer to basename of $0
- Date: Thu, 28 Jul 2011 21:39:36 -0400
- 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=
- In-reply-to: <alpine.LNX.2.01.1107282034110.18508@hp.internal>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CADjGqHuKhx9A3HCUBjU4JgRsbj52s7DQ6HGewT=Y9uRMDGD-fg@mail.gmail.com> <alpine.LNX.2.01.1107282034110.18508@hp.internal>
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author