UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 2.10 Gotchas in set prompt Test Chapter 2
Logging In
Next: 2.12 Automatic Setups for Different Terminals
 

2.11 Faster ksh and bash Startup with $- Test

Do you use the Korn shell - and does your account have an "ENV file" (2.2) (a startup file named in the ENV environment variable)? bash users, you probably have setup files like .bashrc or .bash_login. You might have the same problem (2.9) that C shell users have with .cshrc: noninteractive shells read aliases and other lines that you want to be read only by interactive shells. Speed up your file by adding a test like this:

case 




case $- in
  *i*);;
  *) return 0;;
esac
# COMMANDS BELOW THIS LINE WILL ONLY BE RUN BY INTERACTIVE SHELLS:
   ...

The test checks to see if the shell's -i option is set. If it isn't, the return 0 quits the file.

- JP


Previous: 2.10 Gotchas in set prompt Test UNIX Power ToolsNext: 2.12 Automatic Setups for Different Terminals
2.10 Gotchas in set prompt Test Book Index2.12 Automatic Setups for Different Terminals

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System