I am running RHEL6 (kernel 2.6.32-573.el6.x86_64).
I have aliases which are sourced upon sshing into myserver.
One of these is
alias scl-devtoolset-3='source /usr/local/bin/scls/devtoolset-3'
It is presumably aliased in non-login shells (see below), but sshing gives a login shell, and this is confirmed by the line
shopt -q login_shell && echo 'This is a login shell' || echo 'This is a non-login shell'
in my ~/.bashrc, which produces
This is a login shell
as expected. Thus, I have no idea why/where is the alias set.
How to rationalize this seemingly contradictory circumstance?
Files present in my system:
/etc/profile
/etc/bashrc
/etc/profile.d/*
~/.bashrc
Files not present in my system:
/etc/bash.bashrc
~/.profile
TL;DR
The alias appears to be set (only in non-login shells) by the following lines in /etc/bashrc:
...
if ! shopt -q login_shell ; then # We're not a login shell
...
# Only display echos from profile.d scripts if we are no login shell
# and interactive - otherwise just process them to set envvars
for i in /etc/profile.d/*.sh; do
if [ -r "$i" ]; then
if [ "$PS1" ]; then
. "$i"
else
. "$i" >/dev/null 2>&1
fi
fi
done
...
fi
which source file /etc/profile.d/scl-aliases.sh containing
#!/bin/bash
sources_dir=/usr/local/bin/scls
for scl in `ls $sources_dir`; do
alias scl-$scl="source $sources_dir/$scl"
done
and given that
$ ls /usr/local/bin/scls
devtoolset-3 devtoolset-4 devtoolset-6 python27 python33
This was (partially?) confirmed by executing bash -x at the command prompt after sshing.