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

Re: bash startup scripts - what is an "interactive login" ??

On 2005-07-12, Mark D. Hansen wrote:

> Can anyone clarify for me when the ~/.bash_rc and /etc/bash.bashrc
> scripts get sourced?

     ~/.bash_rc is not a standard file; do you mean ~/.bashrc?

     /etc/bash.bashrc is usually sourced in /etc/profile.

     Both files can be sourced any time you want them to be.

> I read from the man and googling that it is only when an
> "interactive login" shell is created, but what does that mean?

man bash:

       A login shell is one whose first character of argument zero  is  a
       -, or one started with the --login option.

       An  interactive  shell is one started without non-option arguments
       and without the -c option whose standard input and error are  both
       connected  to  terminals  (as  determined  by  isatty(3)),  or one
       started with the -i option.  PS1 is set and $- includes i if  bash
       is  interactive, allowing a shell script or a startup file to test
       this state.

> If I create a new xterm do these scripts get sourced or is it only
> if I do an rlogin, ssh, login ,etc?

      If you call xterm with the -ls option, it opens a login shell,
      i.e., one which sources /etc/profile and ~/.bash_profile.

      If the shell is interactive, but not a login shell (e.g., xterm
      without -ls), it sources ~/.bashrc.

    Chris F.A. Johnson                     <http://cfaj.freeshell.org>
    Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress

Reply to: