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

RE: remote function problems.

> Scott Lipcon wrote:
> > $ ssh hostname zsh -c function
> > slipcon's password:
> > zsh: command not found: function
> > $
> >
> > this is because I load my functions in my .zshrc - they're all in a file
> > called zfunc, and I say:
> >
> >
> > # load functions (necessary for completions)
> > [[ -r $HOME/.zsh/zfunc ]] && source $HOME/.zsh/zfunc
> >
> > in my zshrc.  (which is directly before I load in my completions, which
> > are in $HOME/.zsh/zcomp)
> You should move the code (and anything it depends on) to ~/.zshenv and
> everything will work without the -i.

We already discussed it. IMHO it is bad idea to put this in zshenv. This will be
executed for every shell, including zsh scripts, and not ony slows it down but,
what's worse, function defintions may clash with external commands; it may
redefine some commands script relies upon; etc ... If this happens in
interactive shell, it is more or less acceptable - you get immediate feedback.
But it may cause scripts to behave in unpredictable way.

zshenv is  not needed for scripts - at least, should not be needed. Scripts
should be self-contained. Almost the only use for zshenv is to redefine/augment
default module_path as zsh simply won't be usable without it's modules. Anything
else can be setup as needed in zshrc for interactive shells or in script itself
for scripts.

Why not make your command a shell script in the first place? It could then
source whatever function definitions it needs.


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