From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11558 invoked from network); 23 Sep 1999 16:56:04 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 23 Sep 1999 16:56:04 -0000 Received: (qmail 17555 invoked by alias); 23 Sep 1999 16:55:51 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8035 Received: (qmail 17546 invoked from network); 23 Sep 1999 16:55:49 -0000 From: "Bart Schaefer" Message-Id: <990923164249.ZM27135@candle.brasslantern.com> Date: Thu, 23 Sep 1999 16:42:49 +0000 In-Reply-To: <19990922093920.A24958@ichips.intel.com> Comments: In reply to Clint Olsen "Re: #!/path/to/arch-indep/zsh -f" (Sep 22, 9:39am) References: <19990922015831.A82900@ichips.intel.com> <9909220833.AA27306@ibmth.df.unipi.it> <19990922093920.A24958@ichips.intel.com> X-Mailer: Z-Mail (5.0.0 30July97) To: Clint Olsen , zsh-workers@sunsite.auc.dk Subject: Re: #!/path/to/arch-indep/zsh -f MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Sep 22, 9:39am, Clint Olsen wrote: } Subject: Re: #!/path/to/arch-indep/zsh -f } } On this crappy system (AIX 4.1.X), it must be the multiple level of } indirection problem that Bart mentioned. [...] Bummer... Compiling } a wrapper program again defeats the purpose of having an } architecture-independent launch point. Two remarks: (1) This is what autoloadable shell functions are for. If an already- running zsh loads and executes the function, it can't possibly be the wrong architecture. (2) What you're really asking for is not an arch-indep launch point, but an arch-dependent path to the shell. You can still have that, you just have to do your launching a slightly different way. Here's what you do: Take your launcher script and fix it to pass along a modified $0 file name to zsh, like so: #!/bin/sh if [ -x $OTOOLS/bin/$OS/zsh ]; then exec $OTOOLS/bin/$OS/zsh "$0".real "$@" else exec /usr/intel/bin/zsh "$0".real "$@" fi (Remember, you're in sh, not zsh, so $* does word-splitting; use "$@". If you're really paranoid, use ${1+"$@"} [some old sh turn "$@" into an empty string if there are no arguments at all, rather than into nothing].) Put that in ~/bin (or wherever your scripts are) and call it "launch-zsh" or some such. Now, for every script that you want to be able to launch this way, run mv $script $script.real && ln $script launch-zsh If you don't like the ".real" extension on every file name, put the real script in some other directory and do a more complicated replacement on $0 in the launcher. It's not as clean as what you originally thought of, but it'll work. You can even get as clever as you like with the launcher: #!/bin/sh ZERO=$0.real if [ -f $ZERO ]; then read scratch command switches < "$ZERO" case "$scratch" in '#!') ;; '#!*') switches="$command"; command="$scratch";; *) echo 1>&2 "$0": warning: no '#!' line in "$ZERO";; esac case "$command" in */zsh) if [ -x $OTOOLS/bin/$OS/zsh ]; then exec $OTOOLS/bin/$OS/zsh "$switches" "$ZERO" "$@" else exec /usr/intel/bin/zsh "$switches" "$ZERO" "$@" fi;; *) echo 1>&2 "$0": "$command" is not zsh; exit 1;; esac else echo 1>&2 "$0": launcher found no real script exit 1 fi -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com