Disabling (renaming) system wide /etc/profile
, ~/.profile
is sourced.
After investigating /etc/profile
I saw that, keeping it but commenting the function profile_d ()
~/.profile
is sourced. This function runs the scripts in /etc/profile.d/
.
Disabling them individually I realized that the culprit is /etc/profile.d/bash_completion.sh
.
It reads:
# Check for interactive bash and that we haven't already been sourced.
[ -z "$BASH_VERSION" -o -z "$PS1" -o -n "$BASH_COMPLETION_COMPAT_DIR" ] && return
# Check for recent enough version of bash.
bash=${BASH_VERSION%.*}; bmajor=${bash%.*}; bminor=${bash#*.}
if [ $bmajor -gt 4 ] || [ $bmajor -eq 4 -a $bminor -ge 1 ]; then
[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/bash_completion" ] && \
. "${XDG_CONFIG_HOME:-$HOME/.config}/bash_completion"
if shopt -q progcomp && [ -r /usr/share/bash-completion/bash_completion ]; then
# Source completion code.
. /usr/share/bash-completion/bash_completion
fi
fi
unset bash bmajor bminor
The first line explains why when running the subshell (the second time) things work: environment variables are already set, so the script returns.
The problem is that bash_completion.sh
runs /usr/share/bash-completion/bash_completion
, which is really huge and it is difficult to grasp the problem.