home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 2.5 Tips for Speeding up Slow Logins Chapter 2
Logging In
Next: 2.7 C Shell Setup Files Aren't Read When You Want Them to Be?
 

2.6 Use Absolute Pathnames in Shell Setup Files

One common mistake in shell setup files ( 2.2 ) is lines like these:



`...`
 

source .aliases
echo "Logged in at `date`" >> login.log

What's wrong with those lines? Both use relative pathnames ( 1.21 ) for the files ( .aliases , login.log ), assuming the files are in the home directory. Those lines won't work when you start a subshell ( 38.4 ) from somewhere besides your home directory, because your files .cshrc or ENV (like .kshrc ) are read whenever a shell starts. If you ever use the source or . commands ( 44.23 ) to read the .profile and .login from outside your home directory, you'll have the same problem.

Use absolute pathnames instead. As article 14.11 explains, the pathname of your home directory is in the tilde ( ~ ) operator or the $HOME or $LOGDIR environment variable:

source ~/.aliases
echo "Logged in at `date`" >> ~/login.log

- JP


Previous: 2.5 Tips for Speeding up Slow Logins UNIX Power Tools Next: 2.7 C Shell Setup Files Aren't Read When You Want Them to Be?
2.5 Tips for Speeding up Slow Logins Book Index 2.7 C Shell Setup Files Aren't Read When You Want Them to Be?

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










??????????????@Mail.ru