From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17579 invoked by alias); 27 Jun 2011 16:52:22 -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: 16113 Received: (qmail 22081 invoked from network); 27 Jun 2011 16:52:11 -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,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <110627095140.ZM12634@torch.brasslantern.com> Date: Mon, 27 Jun 2011 09:51:40 -0700 In-reply-to: Comments: In reply to TJ Luoma "Shell scripting with zsh with unknown path" (Jun 27, 10:56am) References: X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Zsh Users Subject: Re: Shell scripting with zsh with unknown path MIME-version: 1.0 Content-type: text/plain; charset=us-ascii 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).