Ubuntu – Is ~/.profile sourced by bash

bash

I'm trying to create a global counter variable to see how many times ~/.profile gets executed. Thus:
In ~/.bashrc:

# ... 
if [ "$PROFILE_EXEC_TIMES" = "" ]; then
 export PROFILE_EXEC_TIMES=0
fi
let "PROFILE_EXEC_TIMES += 1"

In ~/.profile:

# ... 
export PROFILE_EXEC_TIMES
let "PROFILE_EXEC_TIMES += 1"

But when I open a new shell and write echo $PROFILE_EXEC_TIMES, all I get is 1. $PROFILE_EXEC_TIMES must be at least 2. I suspect that ~/.profile isn't sourced by bash… if so, what I need to do in order to check how many times ~/.profile is executed?


Edit:
I've noticed that /etc/gdm/Xsession is sourcing ~/.profile by the following line:

test -f "$HOME/.profile" && . "$HOME/.profile"

and ~/.bashrc is sourced in ~/.profile by the following lines:

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
    fi
fi

Also, I've add the following line to ~/.bashrc & ~/.profile:

echo $(cd ${0%/*} && echo $PWD/${0##*/}) >> /home/myUserName/a

and could see that only one line was added to the file after I logged in to my user.

I want to emphasize that my goal here is:
Finding out how many times ~/.profile is executed when user logs in.

Additional details:

$ uname -a
Linux my-desktop 2.6.32-25-generic #45-Ubuntu SMP Sat Oct 16 19:52:42 UTC 2010 x86_64 GNU/Linux
$ cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.04
DISTRIB_CODENAME=lucid
DISTRIB_DESCRIPTION="Ubuntu 10.04.1 LTS"

Best Answer

From your comments on my original answer, it appears that your real question is "Is ~/.profile sourced by GNOME?" The answer is yes. Look in /etc/gdm/Xsession:

# First read /etc/profile and .profile
test -f /etc/profile && . /etc/profile
test -f "$HOME/.profile" && . "$HOME/.profile"
# Second read /etc/xprofile and .xprofile for X specific setup
test -f /etc/xprofile && . /etc/xprofile
test -f "$HOME/.xprofile" && . "$HOME/.xprofile"

Original Answer

From the manpage of bash:

When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.

So you may have a file called .bash_profile or .bash_login in your home directory. If either of these exists, bash will use it instead of .profile.