On 25 Jun 2022, at 12:36, George N. White III <gnwiii@gmail.com> wrote:


On Fri, Jun 24, 2022 at 7:28 PM Barry <barry@barrys-emacs.org> wrote:

On 24 Jun 2022, at 16:36, Roger Heflin <rogerheflin@gmail.com> wrote:


Trick is add this around the path add.  

If [ $path_add -ne 1 ] ; then
Path addition code
Path_add=1
Fi

That only runs it once.

This is a work around for using ,bashrc when .bash_profile is where this should be done.

I think that advice goes back to a time before modern GUI's.  Now many users have never
encountered a terminal, and distros vary widely in the use of ~/.bashrc, ~/.bash_profle, and
~/.profile.


Actually they are fixing the problem of inheriting .bash_profile from the login to
the gui session to running the shell on login mode. So no this is not out of date
advice.


On my Fedora 35 box, ~/.bash_profile is:

  ----------------------------------ser
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

That has been required since the beginning of time.

You always source .bashrc in the profile.

The reason that you do not set important things in the .bashrc is that if you do
that you cannot override them from the command line.

For example if you set PATH in .bashrc you cannot then change for any sub shells from the command line.

Barry


# User specific environment and startup programs
  ---------------------------

Some distros have complicated ~/.bashrc or `/.bash_profile files with a section devoted to
interactive sessions.   This led to issues where users added settings in the wrong section.  
I often ask users to run a failing command in a terminal where they may see messages
that their GUI tools hide, but getting different behaviours between GUI and terminal has
become a problem.

--
George N. White III

_______________________________________________
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-leave@lists.fedoraproject.org
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org
Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure