From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16951 invoked by alias); 12 Jul 2010 15:57:03 -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: 15170 Received: (qmail 9390 invoked from network); 12 Jul 2010 15:56:59 -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=0.2 required=5.0 tests=BAYES_00, RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_SORBS_WEB autolearn=no version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at biskalar.de does not designate permitted sender hosts) Subject: Re: zsh portable script Mime-Version: 1.0 (Apple Message framework v1081) Content-Type: text/plain; charset=us-ascii From: Sebastian Stark In-Reply-To: <1007130241570.5546@smasher> Date: Mon, 12 Jul 2010 17:35:34 +0200 Cc: zsh-users@zsh.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <1007130241570.5546@smasher> To: Atom Smasher X-Mailer: Apple Mail (2.1081) Am 12.07.2010 um 16:46 schrieb Atom Smasher: > on freebsd, zsh installs as /usr/local/bin/zsh. on linux (and most = other systems?) it installs as /usr/bin/zsh. >=20 > what's the best way to make zsh script portable between linux and = freebsd? >=20 > i could start the script with: > #!/usr/bin/env zsh >=20 > or i could specify that the script be executed as: > zsh script >=20 > is there a better way? /usr/bin/env is not as portable as one might think (see = http://www.in-ulm.de/~mascheck/various/shebang/#env) When I read this I was thinking about it a bit and came to this: ------------------------------------------------ #!/bin/sh if test -z "$ZSH_VERSION" then exec zsh <"$0" fi print "I'm in zsh now!" ------------------------------------------------ Since the script is fed to /bin/sh via stdin it shouldn't be a problem = if it contains zsh-specific syntax after the exec. I never used this = construct and I'm not sure how portable it really is. Also I don't know = if one can assume that /bin/sh understands ,exec' and ,<'. Sebastian=