Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 04-03-2010, 04:49 AM   #16
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198

Originally Posted by forusword View Post
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc

could it be the lack of a line break in the first line here and the use of whitespace in the second line?
I don't think so; if [ -f /etc/bashrc ]; then is valid and there is a space after the "." so that's OK.
Old 04-03-2010, 05:19 PM   #17
Registered: Sep 2003
Location: 19th moon ................. ................Planet Covid ................Another Galaxy;............. ................Not Yours
Posts: 705

Rep: Reputation: Disabled
dot space equals source

Exactly. In fact, to illustrate, please consider this little session:

> echo $SHELL
> 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
echo 'Not Fubar'
Not Fubar
> source
Not Fubar
If '' is not a typo you can use command-not-found to lookup the package that contains it, like this:
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:

> if [ -f ]; then
> .
> 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:

>   .
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:

echo ".bash_profile being run @ `date`"  >>  $HOME/log/login.log
I'll add the appropriate version of that line to my .bashrc:

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.
1 members found this post helpful.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
.bash_profile dimi Linux - General 1 08-23-2005 08:00 PM
.bash_profile sikandar Linux - Software 9 08-31-2003 10:01 AM
Finding Module Dependencies...(Still loading...still loading..still loading..HANG!!!) Aeudian Linux - General 3 08-11-2003 03:31 PM
Finding Module Dependencies.....(still loading....Still loading....still loading) Aeudian Linux - Newbie 1 07-28-2003 02:27 PM
.bash_profile Wasim Haider Linux - General 2 09-16-2002 07:12 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:24 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration