You are not logged in.

#1 2014-05-15 15:47:01

gdkags
Member
Registered: 2010-10-12
Posts: 18

unnecessary lines in default .bash{rc,_profile}?

Ohai,

I recently read the man page for bash because I wondered why there is a .bashrc and a .bash_profile, and what they are used for.

So if I understand this correctly: .bash_profile gets sourced in any case, .bashrc is only used if the invoked shell is interactive.

So in the /etc/skel/ dir are both of these files, but bash_profile is sourcing .bashrc if it exists and then in .bashrc there is a line that exits parsing if the shell is not interactive.
Which looks kinda redundant because it should not have been read in the first place, but still: Is there a reason for those two lines to be there?
Am I missing something?

.bash_profile

[[ -f ~/.bashrc ]] && . ~/.bashrc

.bashrc

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

Offline

#2 2014-05-15 16:34:30

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,601

Re: unnecessary lines in default .bash{rc,_profile}?

They basically do the same, with a little difference.
If bash is invoked as a interactive login shell, bash_profile is used.
If bash is invoked as a interactive shell, that is not a login shell, bashrc is used.

So using bash trough xterm in your WM uses bashrc.

Offline

Board footer

Powered by FluxBB