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

Re: Shell scripting with zsh with unknown path



On Jun 27, 10:56am, TJ Luoma wrote:
} Subject: Shell scripting with zsh with unknown path
}
} The problem is that I don't always know where zsh will be 
} installed. It could be /usr/bin/zsh or /usr/local/bin/zsh or /bin/zsh.

There are several options here.  Among them:

(1) Write your zsh scripts so they can be autoloaded as shell functions,
and place them in directories in your $fpath.  This doesn't work if you
want to run your zsh scripts from other shells.

(2) Use a program to fix the #! line of all your scripts whenever you
install them on a new host.  E.g.

    perl -pi.orig -e 's@^(#!)/.*?/zsh\b@$1$ENV{SHELL}@; last' ...

where "..." is some pattern that matches your script files.

} I have seen perl scripts which have used
} 
}      #!/usr/bin/env perl
} 
} but that did not seem to work for zsh.

I know others here have successfully used this, though it does cause
some complications (can't pass -f to zsh, for example).



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