From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5563 invoked by alias); 28 Jun 2011 00:45:06 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16117 Received: (qmail 3141 invoked from network); 28 Jun 2011 00:44:51 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at vinc17.net does not designate permitted sender hosts) Date: Tue, 28 Jun 2011 02:44:48 +0200 From: Vincent Lefevre To: zsh-users@zsh.org Subject: Re: Shell scripting with zsh with unknown path Message-ID: <20110628004448.GB9177@prunille.vinc17.org> Mail-Followup-To: zsh-users@zsh.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Mailer-Info: http://www.vinc17.net/mutt/ User-Agent: Mutt/1.5.21-6187-vl-r42848 (2011-06-25) 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 - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)