Thanks Greg! These are fantastic pointers. As for the if statement, I was referring to the first one, i.e. if [ "x$SHLVL" != "x1" ]; then ... fi But I think this thread answers my question: http://stackoverflow.com/questions/4511407/how-do-i-know-if-im-running-a-nested-shell James On Wed, Mar 13, 2013 at 4:57 PM, Greg Klanderman wrote: > >>>>> On March 13, 2013 James Jong wrote: > > > 1) What doest the if statement above test? > > whether the file is readable. the loop loads all readable files > matching the pattern /etc/profile.d/*.sh > > > 2) When I run a zsh script, how can I prevent it from running /etc/zshrc? > > zsh -f > > > 3) When I switch to zsh from tcsh on an interactive shell using exec zsh > -l, > > how I can I prevent it from running /etc/zprofile? > > I use "setopt norcs" in my .zshenv and then specifically load the > files I want to load depending on whether the shell is a login shell, > interactive, etc. You could also use "setopt noglobalrcs" which only > prevents loading the global (/etc/...) ones. Note that without the > "-f" command-line option, you cannot prevent loading /etc/zshenv > (alternately /etc/zsh/zshenv on some systems). > > Greg >