Prevent .cshrc customizations from impacting scripts

Aug 01, '05 09:39:00AM

Contributed by: webdeck

This recent hint included a mention of how aliasing rm to rm -i messed up an installer. The way I've always avoided this problem is to place the following line at the top of my .cshrc file:

if (! $?prompt) exit
This causes the .cshrc commands to be skipped if the prompt shell variable is undefined. The prompt shell variable is only defined when the shell is interactive with a terminal.

[robg adds: There are some other methods discussed in the comments to the previous hint, but I felt the topic was worth a hint of its own, in case people are searching on different terms. Please feel free to add your favorite workaround for your favorite shell to the comments...]

Comments (7)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20050725192258497