Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Shell scripting with zsh with unknown path
- X-seq: zsh-users 16117
- From: Vincent Lefevre <vincent@xxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Shell scripting with zsh with unknown path
- Date: Tue, 28 Jun 2011 02:44:48 +0200
- In-reply-to: <r422Ps-1068i-9B5EB01499CF480697563A7E4C94112A@Air.local>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mail-followup-to: zsh-users@xxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <r422Ps-1068i-9B5EB01499CF480697563A7E4C94112A@Air.local>
On 2011-06-27 10:56:35 -0400, TJ Luoma wrote:
> 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.
>
> I have seen perl scripts which have used
>
> #!/usr/bin/env perl
>
> but that did not seem to work for zsh.
I use
#!/usr/bin/env zsh
most of the time, and no problems with that. The only limitation is
that one cannot pass flags, such as -f. In such a case, one needs
something like:
#!/bin/sh
[ -n "$ZSH_VERSION" ] || exec zsh -f -- "$0" ${1+"$@"}
Now, for Emacs users, a consequence is that Emacs no longer sees it
as a zsh script. I have to put
# local variables:
# mode: sh
# eval: (sh-set-shell "zsh")
# end:
in the script. And in the .emacs:
(add-to-list 'safe-local-eval-forms '(sh-set-shell "zsh"))
If you don't have this, Emacs can add something similar for you
in your .emacs (you will have to confirm, as such eval forms can
be insecure).
--
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author