Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Portably checking for shell level



On Tue, 17 Aug 2004, DervishD wrote:

>     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.



Messages sorted by: Reverse Date, Date, Thread, Author