Exactly. In fact, to illustrate, please consider this little session:
Code:
> echo $SHELL
/bin/bash
> ps
PID TTY TIME CMD
6420 pts/7 00:00:00 bash
10118 pts/7 00:00:00 ps
> # So, I'm using bash as my shell.
> cat not_fubar.sh
echo 'Not Fubar'
>. not_fubar.sh
Not Fubar
> source not_fubar.sh
Not Fubar
> .not_fubar.sh
If '.not_fubar.sh' is not a typo you can use command-not-found to lookup the package that contains it, like this:
cnf .not_fubar.sh
>
In bash, a dot followed by a space is the same as the source command.
In fact, if I substitute the trivial shell script for /etc/bashrc, but
take the rest of the code, character for character, spaces and all,
right out the post, it works just fine:
Code:
> if [ -f not_fubar.sh ]; then
> . not_fubar.sh
> fi
Not Fubar
>
In fact, there are two spaces after the dot in the fifth command sequence, and it works just fine. I can place several spaces before
and after the dot:
Code:
> . not_fubar.sh
Not Fubar
>
and it still works just fine. Space is not much of an issue, except for NASA.
OH, and as far as the comment about not having to edit quite so many files to change aliases, etc., yes, some distros, such as the one I use, source a file with a name like .alias or some such from the .bashrc, so they are all in one place.
Now back to your regularly scheduled programming issue.
I have a $HOME/log directory for a variety of purposes. For example, whenever I think there's an issue with files being executed/sourced when the shell starts, such as sourcing .bash_profile, I'll add a line to the files like:
Code:
echo ".bash_profile being run @ `date`" >> $HOME/log/login.log
I'll add the appropriate version of that line to my .bashrc:
Code:
echo ".bashrc being run @ `date`" >> $HOME/log/login.log
and if I have access to /etc/bashrc or if it's being sourced from .bash_profile then I can also log when it's being sourced by the .bash_profile. In one older version of a distro I use, there was a bug in the distro, /etc/profile was actually being executed twice. I tracked it down using this method, and set up a workaround.
Hope this helps.