zsh-workers
 help / color / mirror / code / Atom feed
From: Greg Klanderman <gak@klanderman.net>
To: zsh-workers@zsh.org
Subject: Re: loading user startup files for zsh scripts
Date: Thu, 10 Feb 2011 18:10:33 -0500	[thread overview]
Message-ID: <m3r5bfcwpi.fsf@klanderman.net> (raw)
In-Reply-To: <110210095253.ZM30860@torch.brasslantern.com> (Bart Schaefer's message of "Thu, 10 Feb 2011 09:52:52 -0800")

>>>>> On February 10, 2011 Bart Schaefer <schaefer@brasslantern.com> wrote:

> Hmm.  Yeah, I tried examining things like $funcfiletrace etc. and they
> don't provide any additional information.

Thanks for really digging Bart!

> I can suggest a draconian solution: make update more than a suggestion.

Sadly, draconian solutions are just not acceptable short of needing to
patch a security vulnerability.  :-)

> Change your shared file to have it require that $0 be passed as an
> argument, e.g.

> 	source /the/shared/zshenv $0

> This shows up as $1 in your shared file.  Have the file do NOTHING if
> there is no $1, otherwise test $1 against $ZSH_NAME, etc.  Maybe if
> the shell is interactive, print a warning.

Now that's actually got me thinking of a less draconian variant which
I like; if $0 is passed in (as $1) then I can DTRT, otherwise (if they
have not updated ~/.zshenv), if not a login or interactive shell then
do nothing.  They only lose the benefit of the shared file in the case
that's ambiguous and which also happens to be the case which probably
almost nobody is actually taking advantage of.

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?

thanks!
Greg


  reply	other threads:[~2011-02-10 23:19 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 [this message]
2011-02-11  1:42                   ` Greg Klanderman
2011-02-11  3:29                     ` Bart Schaefer
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=m3r5bfcwpi.fsf@klanderman.net \
    --to=gak@klanderman.net \
    --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).