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

Re: How do you decide whether to make something a function or a script?



Grant Taylor wrote on Sat, 08 Sep 2018 19:55 -0600:
> I upgrade from functions to scripts when I want to be able to run the 
> command from outside of the shell, like an ssh remote command:  ssh 
> myserver openDB.  The remote command doesn't launch the shell, thus 
> doesn't have access to functions, much less aliases. But it does have
> access to scripts if I have my PATH configured properly.

The remote command in 'ssh myserver foo bar' indeed doesn't have
access to functions or aliases, but it does go through a shell on the remote
end.  It simply uses a non-interactive shell.  That's why changes to PATH in
zshenv are honoured by ssh commands, and why functions aren't available
(zshrc isn't read).

Cheers,

Daniel
(I don't mean to nitpick; sometimes this distinction matters.)



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