Rather than trying to modify code, the standard practice is to create a file to flag whether something's run:
if [[ ! -f ~/.first_run ]]
then
echo "Welcome to $HOSTNAME!"
touch ~/.first_run
fi
This approach is simpler and allows you to e.g. symlink all default .bashrc
files to the same system-wide standard and more robustly determine the user's state in other tools.