zsh-users
 help / color / mirror / code / Atom feed
From: TJ Luoma <luomat@gmail.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: how to refer to basename of $0
Date: Thu, 28 Jul 2011 21:39:36 -0400	[thread overview]
Message-ID: <CADjGqHt4-PnBNC0QgyRVw0H-HtCWcRp_aA7N3zJoH+xK_676kw@mail.gmail.com> (raw)
In-Reply-To: <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


  reply	other threads:[~2011-07-29  1:40 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-28 22:55 TJ Luoma
2011-07-28 23:54 ` Tomasz Moskal
2011-07-29  0:24 ` Phil Pennock
2011-07-29  1:30   ` Tomasz Moskal
2011-07-29  0:44 ` Benjamin R. Haskell
2011-07-29  1:39   ` TJ Luoma [this message]
2011-07-29  2:06     ` Tomasz Moskal
2011-07-29  4:04     ` Bart Schaefer
2011-07-29  4:50       ` TJ Luoma
2011-07-29 11:48       ` Tomasz Moskal
2011-07-29 14:08         ` Benjamin R. Haskell
2011-07-29 22:30           ` Bart Schaefer
2011-07-30 19:43             ` Greg Klanderman
2011-07-29  3:05   ` TJ Luoma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADjGqHt4-PnBNC0QgyRVw0H-HtCWcRp_aA7N3zJoH+xK_676kw@mail.gmail.com \
    --to=luomat@gmail.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).