zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: loading user startup files for zsh scripts
Date: Thu, 10 Feb 2011 19:29:45 -0800	[thread overview]
Message-ID: <110210192945.ZM31349@torch.brasslantern.com> (raw)
In-Reply-To: <m3ipwrcpo2.fsf@klanderman.net>

On Feb 10,  8:42pm, Greg Klanderman wrote:
}
} > 	source /the/shared/zshenv $0
} 
} Hmmm, AFAICT, when loading .zshenv, $0 is /bin/zsh even for shell
} scripts.  It does contain the script path once in the script.

Well, that certainly takes me by surprise, because I was sure I'd
tried that ... but indeed looking through init.c the script name of
$0 isn't set up until after ALL the init files have been read.  

This is odd considering that $* has already been set to the script
arguments by the time .zshenv is processed.  It also means that zsh
will read all the init files before discovering that it can't read
the script file.

I'm also finding it a little weird that $0 apparently might be a
metafied string, since setupshin() believes that unmeta(runscript)
is necessary before calling e.g. access().  As far as I can tell
the value would never be unmetafied before being returned via $0,
so that would imply there are circumstances in which $0 is broken.
I don't know what they'd be.

Earlier:

} On a related note, would you be opposed to adding some way to find out
} definitively whether you're running as a script from within zsh?
} Would adding a new parameter be best?  Can you suggest a name?  Is
} runscript != NULL in zsh_main() the right condition to use?  Or maybe
} just set some parameter to the value of runscript when set?

I'm inclined to suggest ZSH_SCRIPT to be initialized from runscript.
I'd also like to get ZSH_INTERPRETER to be the actual path to the shell
executable, but I suspect that's not universally available from the OS.

Returning to your original problem ... I don't suppose all these user's
hosts are running linux?  You can examine /proc/$$/cmdline to find out
if a script name appears.


  reply	other threads:[~2011-02-11  3:30 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-07 20:34 Greg Klanderman
2011-02-08  5:33 ` Bart Schaefer
2011-02-08 17:09   ` Greg Klanderman
2011-02-08 17:20     ` Peter Stephenson
2011-02-09  0:37       ` Greg Klanderman
2011-02-09  4:58         ` Bart Schaefer
2011-02-09 15:32           ` Greg Klanderman
2011-02-09 16:01           ` Greg Klanderman
2011-02-09 16:53             ` Bart Schaefer
2011-02-10 16:30               ` Greg Klanderman
2011-02-10 17:52                 ` Bart Schaefer
2011-02-10 23:10                   ` Greg Klanderman
2011-02-11  1:42                   ` Greg Klanderman
2011-02-11  3:29                     ` Bart Schaefer [this message]
2011-02-11 16:28                       ` Greg Klanderman
2011-02-11 17:26                         ` Bart Schaefer
2011-02-11 17:47                           ` Peter Stephenson
2011-02-11 18:36                           ` Bart Schaefer
2011-02-11 19:25                         ` Peter Stephenson

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=110210192945.ZM31349@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@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).