From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22166 invoked from network); 13 Jan 1999 11:35:01 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 13 Jan 1999 11:35:01 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id GAA29291; Wed, 13 Jan 1999 06:33:40 -0500 (EST) Resent-Date: Wed, 13 Jan 1999 06:33:40 -0500 (EST) Message-Id: <9901131117.AA60050@ibmth.df.unipi.it> To: zsh-workers@math.gatech.edu Subject: Re: How sensible is ... ? In-Reply-To: "Phil Pennock"'s message of "Wed, 13 Jan 1999 11:09:51 NFT." <19990113110951.A6955@fysh.org> Date: Wed, 13 Jan 1999 12:17:24 +0100 From: Peter Stephenson Resent-Message-ID: <"ruJs11.0.c97.KI8ds"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/4896 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Phil Pennock wrote: > > #!/bin/zsh -f > > case $context in > > toplevel) alias leave=exit ;; > > function) alias leave=return ;; > > esac > > Actually, I've just thought of [[ -o interactive ]] -- always the way. > > Is this a sufficient test? It /seems/ to work as I want ... In this particular case, you don't need it, since return will function like exit in a script. I've thought of a hack which is pretty much guaranteed to work (I think): foo=global local foo >/dev/null if [[ $foo = global ]]; then print At top level else print Inside a function fi The nasty bit is the `local foo' which prints the status of $foo if it already exists. I keep thinking we ought to do something about that. -- Peter Stephenson Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy