Login Initaliztion

There are some observations I have made / struggled with on Leap 42.3 login.

  1. LESS variable is set.

While on the surface this seams harmless, it interferes with other applications. In my case, I am working on a software project. I use Mercurial for my Version control system.
Mercurial uses LESS to set appropriate defaults if it is not already set. Unfortunately this is being set by /etc/profile.

Example: in a new mercurial repository with no changes, I type hg status. Normally, this would simply return. However with the LESS setting, it always pops into a blank less screen that
I have to quite from. This is very annoying and contrary to expected behavior.

The obvious solution is to unset LESS less. This is indeed what I do. I do find it unfortunate that I have had to do this.

  1. When you login to a bash session, the following scripts are sourced in order:

/etc/profile
~/.bash_profile
~/.bash_login
~/.profile

In addition, when an interactive bash shell is started that is not a loign shell, the following scripts are sourced:

/etc/bash.bashrc
~/.bashrc

The order here is very important. For a user login, .bash_profile, .bash_login, .profile and .bashrc are available for setting their environment.

.bash_profile, .bash_login and .profile are used to setup static setting that need to be set only once. For example the PATH variable is set here.

.bashrc is typically use for setting environment that may change or need to be reset between bash instances.

I typically use .bash_profile and .bashrc for my uses (I do source .alias if it exists from .bashrc). It is important that .bash_profile is run first, as it set static setting
that may be used by .bashrc.

Unfortunately, /etc/profile source the following:

.alias
.bashrc
.bash_profile

In that order. This is completely backwards and breaks expected behavior. I have aliases and other setting that fail in .alias and .bashrc because .bash_profile has not been sourced
as expected.

Most trubling is that .alias is being source first. Typically sourcing .alias is a user discretion from .bashrc. Indeed the default out of the box .bashrc script for Leap 42.3 does just this.
This means that .alias is being sourced from /etc/profile and .bashrc (twice) before .bash_profile.

I am wondering why this is being done. My environment relies on expected order of scripts being sourced. I have had to do a good amount of coding to ensure that the proper order
is followed. I have hacked .alias to insure that it is only run once.

You have my sympathies.

My personal opinion is that “/etc/profile” should be very small. And it should be under control of the local system administrator, rather than the distribution.

That’s the way it always was with traditional BSD unix and SunOS unix.

Somehow, the linux tradition is to have “/etc/profile” loaded with stuff that I neither need nor want.

And I should clarify. I normally use “csh” (actually “tcsh”) rather than bash. So the relevant files are “/etc/csh.cshrc” and “/etc/csh.login” for “csh” users.

In any case, if you read through “/etc/bash.bashrc”, you will find that there’s a workaround that should help you with your problem. Simply create the file “.bash.expert” in your home directory, and add whatever commands that you want.

The system wide “/etc/bash.bashrc” notices that you have that file, and runs it (sources it), and then skip a lot of what you probably don’t want from the system wide file. I use “.bash.expert” to undo a few things like alias. Then I use “.bashrc” to do the things that I want. Except, for me, it is “.csh.expert” to undo things, and “.cshrc” and “.login” to do what I really want.

The question is, do we want a system which “works for newcomers « out of the box »” or, do we want a system which “works only for experienced system administrators”?
[HR][/HR]Given the current “state of the game”, my vote is, for the first option – despite the inconvenience it produces for system administrators … >:)

We want a system that works for new users. This is exactly why this needs to be fixed. .alias should never be run before .bash_profile! The current setup is very new user unfriendly IMO.

I am actually working on a OSS project that allows users to initialize their login environments very quickly and easily. I will look at the .bash.expert and see if it can be used. Unfortunately,
this would at best be an openSUSE kluge added to my project (actually the second in this case).

I use openSUSE because it still supports my 32-bit system and has the apps I require available (after some effort to add the repos). I would never recommend it for newcomers as the
learning curve is much higher than many other distributions. Mint Linux is usually my first recommendation. I know of many others who have abandoned openSUSE because of its over
the top non-traditional / broken behavior.