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

Re: loading user startup files for zsh scripts



On Feb 11, 11:28am, Greg Klanderman wrote:
}
} >>>>> On February 10, 2011 Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
} > 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().
} 
} Did you note this line near the top of zsh_main():
} 
} |    for (t = argv; *t; *t = metafy(*t, -1, META_ALLOC), t++);
} 
} i.e. all the argv arguments are metified early on.

Indeed.  Still, I must be missing where the un-metafication happens in
parameter substitution.

} > I'm inclined to suggest ZSH_SCRIPT to be initialized from runscript.
} 
} How is the patch below?

Looks basically as I was expecting, though it brings up another question:
Why have zsh_name et al. hanging around permanently as globals when the
strings get ztrdup()'d to set the parameters?  There are some cases
where the global gets used more than once, but zsh_name (and after this
patch zsh_script, among others) are only used in createparamtable(),
which is called exactly once.

I suppose it's easier than trying to pass them back and forth through
all the functions that perform shell initialization via zsh_main().

} I can add doc if you like it.. one open
} question is whether you want $ZSH_SCRIPT to be unset or empty when not
} running a script; currently it would be empty, which might be useful
} for detecting whether zsh is providing that parameter.

I think empty is OK, but let's hear from PWS.

} > 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.
} 
} Oooh that's tricky, yes all are a variety of linux distros, mostly
} debian/ubuntu and FC/RHEL/Centos.  Still would have to parse it and
} deal with the nul byte separators, yuck.

Nul byte separators are no problem, zsh's IFS has nul in it by default.

    print -l -- $(</proc/$$/cmdline)

But it's true you would then have to skip over shell options to find
the script name.  I don't suppose anyone out there has written a
zparseopts spec that matches the zsh invocation-time option set?



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