Using MSYS2, if I run msys2_shell.bat, mintty opens a bash login shell, but ~/.profile does not get sourced.
Anyway if I run /bin/bash --login inside mintty, ~/.profile get sourced. Why?
The same happens if I run path\to\msys64\bin\bash.exe --login via Windows prompt instead of msys2_shell.bat.
PS: I tried also with .bash_profile.
Disabling (renaming) system wide
/etc/profile,~/.profileis sourced.After investigating
/etc/profileI saw that, keeping it but commenting the functionprofile_d ()~/.profileis 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:
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.shruns/usr/share/bash-completion/bash_completion, which is really huge and it is difficult to grasp the problem.