Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: loading user startup files for zsh scripts



>>>>> On February 10, 2011 Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> 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



Messages sorted by: Reverse Date, Date, Thread, Author