If you've buried commands after
(! $?prompt) that should only be run
on interactive shells or at login time, then you may have trouble.
There are workarounds. What you'll need depends on the problem you're trying to work around.
The version of which on the CD-ROM works without reading your .cshrc file, so there's no problem there.
Here's a way to stop the standard which from reading parts of
your .cshrc that you don't want it to read.
The first time you log in, this scheme sets a CSHRC_READ
The variable will be copied into all
(like the one that which
In subshells, the test
($?CSHRC_READ) will branch to the end of your
if (! $?prompt) goto cshrc_end # COMMANDS BELOW HERE ARE READ ONLY BY INTERACTIVE SHELLS: alias foo bar ... if ($?CSHRC_READ) goto cshrc_end # COMMANDS BELOW HERE ARE READ ONLY AT LOGIN TIME: setenv CSHRC_READ yes ... cshrc_end:
# at JOBS RUN INTERACTIVE SHELLS ON MY BUGGY VERSION OF UNIX. # WORKAROUND IS HERE AND IN THE at ALIAS BELOW: if ($?AT) goto cshrc_end ... alias at '(setenv AT yes; \at \!*)' ... cshrc_end:
Most modern versions of at save a copy of your environment and restore it, later, when the at job is run. At that time, the AT environment variable will be set; the C shell will skip the parts of your .cshrc that you want it to. It's ugly, but it works.