Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: How sensible is ... ?
- X-seq: zsh-workers 4896
- From: Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx
- Subject: Re: How sensible is ... ?
- Date: Wed, 13 Jan 1999 12:17:24 +0100
- In-reply-to: "Phil Pennock"'s message of "Wed, 13 Jan 1999 11:09:51 NFT." <19990113110951.A6955@xxxxxxxx>
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 <pws@xxxxxxxxxxxxxxxxx> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy
Messages sorted by:
Reverse Date,
Date,
Thread,
Author