Re: su 5.2.1 does not invoke bash as a login shell when stdin is from a pipe
- From: slakmagik <j@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 10 Sep 2006 08:55:26 GMT
On 2006-09-09 Sat 18:25:28, Angel Tsankov wrote:
....test cases snipped...Here's a scenario in which su from coreutils 5.2.1 does not
invoke bash as a login shell:
Is this a problem in su and if so, is there a patch for it?
According to the bash man page, .bash_profile is read for an
interactive
login shell. When standard input is a pipe, the shell is not
interactive, unless bash is invoked with the -i option.
Read and man pages caerfully (emphasys added):
[...] When bash is invoked as an interactive login shell, or as A
NON-INTERACTIVE LOGIN SHELL WITH THE --LOGIN OPTION, it first
reads and executes commands from the file /etc/profile, if that
file exists. After reading that file, it looks for
~/.bash_profiles, ~/.bash_login, and ~/.profile, in that order,
and reads and executes commands from the first one that exists
and is readable.[...]
And, according the the su man page, the - option to su should
start a login shell. The /etc/profile file does not exist, so
bash should read ~/.bash_profile which exists and is readable.
That may not precisely correct. My man page (I may use a different set
of tools) says (emphasis added) "The optional argument - may be used
to provide an environment SIMILIAR to what the user would expect HAD the
user logged in directly." I've experienced a similar issue running
commands from vim and this:
su - -l -c foo
works fine. HTH.
.
- Follow-Ups:
- Re: su 5.2.1 does not invoke bash as a login shell when stdin is from a pipe
- From: Angel Tsankov
- Re: su 5.2.1 does not invoke bash as a login shell when stdin is from a pipe
- References:
- Re: su 5.2.1 does not invoke bash as a login shell when stdin is from a pipe
- From: Angel Tsankov
- Re: su 5.2.1 does not invoke bash as a login shell when stdin is from a pipe
- Prev by Date: Re: file system inconsistency
- Next by Date: Re: file system inconsistency
- Previous by thread: Re: su 5.2.1 does not invoke bash as a login shell when stdin is from a pipe
- Next by thread: Re: su 5.2.1 does not invoke bash as a login shell when stdin is from a pipe
- Index(es):
Relevant Pages
|