Re: ~/.profile and ~/.bash_profile aren't executed on login
On Sun, Dec 10, 2017 at 1:41 AM, Yuri wrote: > On 12/09/17 15:24, Chet Ramey wrote: > >> Of course not: that's not a login shell. As the documentation says, >> >> "A login shell is one whose first character of argument zero is a -, or >> one started with the --login option." >> >> The INVOCATION section of the manual page explains it in exhaustive >> detail. >> > > > Ok, but that's not what my situation is. I am just logging in, using the > display manager, when user has /usr/local/bin/bash as the shell in passwd. > > Why doesn't it execute ~/.profile? > > > Yuri > > > .profile is supposed to be a file that is read only once per login, so that you can do initialization there. When you run the shell after login it doesn't read this file anymore (there are other initialization files eg .bashrc that are read every time) There is a couple of tricks coming from the history of Unix to tell a shell that it should do this initialization and these tricks are used by the programs handling the login when they start a shell. However, the way you log in to your system seems to not involve bash (or even a shell), then when you start a terminal, bash is invoked as a non-login interactive shell. You can read more there: http://mywiki.wooledge.org/DotFiles
Re: ~/.profile and ~/.bash_profile aren't executed on login
On 12/09/17 15:24, Chet Ramey wrote: Of course not: that's not a login shell. As the documentation says, "A login shell is one whose first character of argument zero is a -, or one started with the --login option." The INVOCATION section of the manual page explains it in exhaustive detail. Ok, but that's not what my situation is. I am just logging in, using the display manager, when user has /usr/local/bin/bash as the shell in passwd. Why doesn't it execute ~/.profile? Yuri
Re: ~/.profile and ~/.bash_profile aren't executed on login
On 12/9/17 6:09 PM, Yuri wrote: > On 12/09/17 15:01, Chet Ramey wrote: >> Since it doesn't happen on any other OS, I suspect an issue with either the >> FreeBSD port or the pathname that appears in argv[0] when the shell is >> started, which is what bash uses to detect that it's been invoked as a >> login shell. > > > The full path is /usr/local/bin/bash as set in passwd db. It doesn't run > ~/.profile when I run it manually using this path. Of course not: that's not a login shell. As the documentation says, "A login shell is one whose first character of argument zero is a -, or one started with the --login option." The INVOCATION section of the manual page explains it in exhaustive detail. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: ~/.profile and ~/.bash_profile aren't executed on login
On 12/09/17 15:01, Chet Ramey wrote: Since it doesn't happen on any other OS, I suspect an issue with either the FreeBSD port or the pathname that appears in argv[0] when the shell is started, which is what bash uses to detect that it's been invoked as a login shell. The full path is /usr/local/bin/bash as set in passwd db. It doesn't run ~/.profile when I run it manually using this path. Yuri
Re: ~/.profile and ~/.bash_profile aren't executed on login
On 12/09/17 14:59, Bob Proulx wrote: How is the user logging in? Are they logging in with 'ssh' over the network? Or are they logging in through an "xdm" X Display Manager login from a graphical login display? User logs in locally through the display manager. Yuri
Re: ~/.profile and ~/.bash_profile aren't executed on login
On 12/9/17 5:14 PM, Yuri wrote: > None of these files are executed when bash is a user's default shell on > FreeBSD. > No special options were selected. Despite shell.c saying that they should > be executed they just aren't. > > Is this a bug? Since it doesn't happen on any other OS, I suspect an issue with either the FreeBSD port or the pathname that appears in argv[0] when the shell is started, which is what bash uses to detect that it's been invoked as a login shell. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: ~/.profile and ~/.bash_profile aren't executed on login
Yuri wrote: > None of these files are executed when bash is a user's default shell on > FreeBSD. > No special options were selected. Despite shell.c saying that they should be > executed they just aren't. How is the user logging in? Are they logging in with 'ssh' over the network? Or are they logging in through an "xdm" X Display Manager login from a graphical login display? If from 'ssh' then that is the standard Unix login path with no surprises. If from a graphical login display, which I think most likely is the case, then it all depends upon how the shell is launched from that point. The shell looks at its own name, or the -l or --login option, to determine if it is a login shell or not. If it is a login shell then it sources the login files. If not then it does not and sources the .bashrc environment file all as documented in the manual. The most typical problem IMNHO is that graphical login managers should set things up for sourcing the login files but by default do not. I am not familiar with BSD. I am only familiar with the GNU/Linux distributions and they often fail to set things up properly to source the login files correctly. That is not a bug in bash but is a bug in the graphical login environment. This is also a case of "bike shedding" because this is something that everyone seems to have an opinion on about how this should be done. And the opinions conflict with each other. And therefore it will likely never get resolved where it works automatically without individual customization to make it work. If your environment has the capability for $HOME/.xsessionrc then that is usually the simplest suggestion to place login environment setting actions there. However note that it is a #!/bin/sh script and not a bash script and therefore should use only POSIX portable shell syntax in that file. And also note that there are many other configurations possible too. I personally do something quite different for example. Beyond this any other suggestions would require a *long* discussion of how each graphical login environment works. Therefore more information about your environment would be needed. > Is this a bug? I feel confident that it is a consequence of how the shell is started. Bob
~/.profile and ~/.bash_profile aren't executed on login
None of these files are executed when bash is a user's default shell on FreeBSD. No special options were selected. Despite shell.c saying that they should be executed they just aren't. Is this a bug? Yuri