From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17300 invoked by alias); 12 Jul 2010 15:45:30 -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: 15169 Received: (qmail 8561 invoked from network); 12 Jul 2010 15:45:28 -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:45:18 +0200 User-Agent: KMail/1.13.2 (Linux/2.6.32-22-generic; KDE/4.4.2; x86_64; ; ) References: <1007130241570.5546@smasher> <201007121737.21296.joke@seiken.de> In-Reply-To: <201007121737.21296.joke@seiken.de> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart5515020.i6oydu7TSG"; protocol="application/pgp-signature"; micalg=pgp-ripemd160 Content-Transfer-Encoding: 7bit Message-Id: <201007121745.20332.joke@seiken.de> --nextPart5515020.i6oydu7TSG Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Monday 12 July 2010 17:37:19 Joke de Buhr wrote: > 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? >=20 > Using env doesn't solve the problem either. There is no guarantee the "en= v" > program is installed under /usr/bin/env. It may as well be installed under > /usr/local/bin/env. >=20 > But every unix should have a bourne shell compatible shell located at > /bin/sh. You can use a bourne shell compatible code snippet and call zsh > from it. If PATH contains zsh than this will do the trick. >=20 >=20 > #!/bin/sh >=20 > if [ -z "$ZSH_VERSION" ]; then > ## searching PATH for zsh executable > exec zsh $* < $0 >=20 > ## no zsh detected > exit 1 > fi >=20 > ## zsh should be running now. do zsh stuff > print "hello" sorry, the correct version should be: #!/bin/sh =20 if [ -z "$ZSH_VERSION" ]; then ## searching PATH for zsh executable exec zsh $0 $* ## no zsh detected exit 1=20 fi ## zsh should be running now. do zsh stuff print "hello" --nextPart5515020.i6oydu7TSG 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) iQG7BAABAwAlBQJMOziOHhhoa3A6Ly9wb29sLnNrcy1rZXlzZXJ2ZXJzLm5ldAAK CRCWUloJhwFWxufhC/97vTprTsbnL94kCc2R0eY1pw48Dg9+mnVLi41P7dzrUjzx oEQLBeme1/RoVpKXfNuU1BoOzpfDq+vL+fe8Rj0qWUGmYOihD83L38Mi8NfPahSm XCW7ZQEzXn8dPAqnavbVBpEavcg7Ofb4VX1VYebit6y156t9kb+VneccTmqkQsKW 3DS9juQwx5rz403F+v40v9PMKrsDNzev0x/7TeLs075agB/yHBWgCKFoyb0EaYMz xjsePfkCz1LC17fcRarDHG99mwPwPqYrHahPAVcv9KrPFNSkAOslc5P3RFUNRTpm Yay+IBwyCzPyPPxRrHE/M6HnHRw5mvv7JtyYxlpnk9U5MTrZQFK6qmTc1oos2n7x y1WEcAE+Iw/ZoJTVmE3u63oWAuU3Tu8TP2Q7DmVnfiIGdQ6RnEEOHgwgqPMolbJ8 sM7MAfw1b5WdUpQ4BvbCdI5LA0n+SeK1YYn76hTyMGu2TkXyqqpykwy2RDs/0Ssw Ik4qsL4iTNd/tcLZ7Dg= =TzzX -----END PGP SIGNATURE----- --nextPart5515020.i6oydu7TSG--