Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Portably checking for shell level
- X-seq: zsh-users 7880
- From: DervishD <raul@xxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Portably checking for shell level
- Date: Wed, 18 Aug 2004 10:10:03 +0200
- In-reply-to: <Pine.LNX.4.61.0408171427320.32066@xxxxxxxxxxxxxxxxxx>
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Organization: Pleyades
- References: <20040817185940.GA32231@DervishD> <Pine.LNX.4.61.0408171427320.32066@xxxxxxxxxxxxxxxxxx>
Hi Bart :)
* Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> dixit:
> > I have a shell script that cannot be sourced, because it must be
> > run in a clean environment. Under zsh I achieve this using 'emulate
> > -L zsh', or just by checking '$SHLVL' if the script won't run just by
> > defaulting the ZSH options. The problem is: how to do this portably?
> Try examining the value of "$-". That's not foolproof, but at least it
> can tell you whether someone is "."-ing your script into an interactive
> shell.
But the problem is that, in the better case, that only tells me
if the '-i' option was used, and SUS doesn't specify options to the
shell binary. I don't know how to otherwise use '$-' to avoid
sourcing. I'm afraid there is no portable way of doing this :(
Thanks for the help, Bart :)
Raúl Núñez de Arenas Coronado
--
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author