[oclug] set $PATH

Bart Trojanowski bart-oclug at jukie.net
Fri Jul 11 08:53:09 EDT 2003


* Joe Burpee <jeb at burkby.com> [030711 00:39]:
> > One solution would be to have ~/.xsession source ~/.bash_profile.
>  
> This may be a bit unsafe since it causes the profile to be sourced
> *after* the automatic sourcing of bashrc.  It seems tidier (assuming
> Xsession is broken and you can't fix it) just to run a login shell in
> ~/.xsession, which at least gets the sourcing order right.

So how about something like this:

----- .bash_profile -----

export BASH_PROFILE_READ=`date +%s`

# ... do all the .bash_profile stuff now ...

----- end -----

Now, if .bash_profile is read it will export the time it was read.

----- .bash_profile -----

BASH_PROFILE_TIME=`stat -c%Y ~/.bash_profile`

if [ ${BASH_PROFILE_TIME} -gt ${BASH_PROFILE_READ-0} ] ; then
	. ~/.bash_profile
endif

# ... do all the .bashrc stuff now ...

----- end -----

Each time you start a new shell .bashrc gets run.  At this time there
is a test to make sure that .bash_profile was read at least once, and if
.bash_profile was modified it will be read again.

Thoughts?

Should .bashrc blindly source .bash_profile and have .bash_profile doing
the checks?

B.

-- 
				WebSig: http://www.jukie.net/~bart/sig/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://tux.oclug.on.ca/pipermail/oclug/attachments/20030711/54a37ec3/attachment.bin


More information about the OCLUG mailing list