From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16779 invoked by alias); 12 Jul 2010 15:37:50 -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: 15167 Received: (qmail 963 invoked from network); 12 Jul 2010 15:37:38 -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: pass (ns1.primenet.com.au: SPF record at seiken.de designates 94.23.38.107 as permitted sender) From: Joke de Buhr To: zsh-users@zsh.org Subject: Re: zsh portable script Date: Mon, 12 Jul 2010 17:37:19 +0200 User-Agent: KMail/1.13.2 (Linux/2.6.32-22-generic; KDE/4.4.2; x86_64; ; ) References: <1007130241570.5546@smasher> In-Reply-To: <1007130241570.5546@smasher> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart2029167.S4epxCkDMJ"; protocol="application/pgp-signature"; micalg=pgp-ripemd160 Content-Transfer-Encoding: 7bit Message-Id: <201007121737.21296.joke@seiken.de> --nextPart2029167.S4epxCkDMJ Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Monday 12 July 2010 16:46:22 Atom Smasher wrote: > 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? Using env doesn't solve the problem either. There is no guarantee the "env"= =20 program is installed under /usr/bin/env. It may as well be installed under= =20 /usr/local/bin/env. But every unix should have a bourne shell compatible shell located at /bin/= sh.=20 You can use a bourne shell compatible code snippet and call zsh from it. If= =20 PATH contains zsh than this will do the trick. #!/bin/sh =20 if [ -z "$ZSH_VERSION" ]; then ## searching PATH for zsh executable exec zsh $* < $0 ## no zsh detected exit 1=20 fi =20 ## zsh should be running now. do zsh stuff print "hello" --nextPart2029167.S4epxCkDMJ Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQG7BAABAwAlBQJMOzavHhhoa3A6Ly9wb29sLnNrcy1rZXlzZXJ2ZXJzLm5ldAAK CRCWUloJhwFWxjylC/9ElVsOLgJvbfqEvYEDHNejgQjCfB/2gyCdzI3YwskAxVvx DY2KXcRBEGdBFTVwZzUJqTYxpmbfnEc7qilQfpX0Pcb98xYw5HnF3FsniWd5Sj49 n4RYNKaz154ouGNFIujX+fY6+CjpQW+YBCSy6IKa9SLfjMigCl49zd9NWlIbivxA hoAIFujCYW2P1/LuHsLYP6hk7fRTcaidXtrcj0HfjryNOviaytyPrlG4dGpySUGC q1taZU1EET7vcBtAa09PuuXSHcYmf3SqxSxsu6ifZDWrHm7rxDzKtMPpGaXooA74 DMwHpWg/ILdtLuQEak4AA9XXV2ajSg2/wdLOV9DnqW0blvCH9hXQdlNJn+IkPKnE Zo1F2cS5jXZX6qxt90k+y4JALn1r4CTip6xFp9/banIn+J9kPBsxxbY5cP0LIKom aDjF4+EqAvq5MRlCiDLgCwvMMOU6ZpInN1lc4YYx1wJ/ICHPfAtSNjTBNe6CsmtF MwgXCaRPmv/IiObg8/Q= =1V2z -----END PGP SIGNATURE----- --nextPart2029167.S4epxCkDMJ--