[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: login shell VS interactive shell



Joao Ferreira Gmail <joao.miguel.c.ferreira@gmail.com> wrote:
> I read a text about bash that mentions a difference between "login
> shell" and "interactive shell".

> I'm affraid I don not know the difference. Can anyone enlighten me ?

I've always found bash to be singularly unhelpful with its approach to
.bash_profile and .bashrc.

Many years ago I used (t)csh and its approach seemed to be logical
and self-consistent: .cshrc is always run, *and* .login is run for
the first interactive (login) shell. This allowed me to put "run once"
configurations into .login and "every time" configurations in .cshrc.

These days I've taken this approach with bash, and I put environment
variables and other preparation into .bash_profile, and every-time
configuration into .bashrc (functions, aliases, terminal setttings,
etc.) with interactive items protected by an « if test -n "$PS1"... »
construct. The final piece of the jigsaw is a check at the top of .bashrc
to run .bash_profile  - but only if it's not already been run - and a
check at the bottom of .bash_profile to chain .bashrc - again, provided
it's not already being run.

Code samples available on request (to the list).
Chris


Reply to: