Does this mean that 'su - glibc' should always start bash
as a login shell, i.e. with --login?


If no, what is "an
environment similar to what the user would expect had the user
logged in directly"?

It means "whatever the shell does when it finds a "-" as first character in argv[0]. Bash's manpage says that " A login shell is one whose first character of argument zero is a - , or one started with the --login option." so the result of su - user should be the same as su user
--login.


If so, then why do the following commands
still cause bash not to read ~/.bash_profile:

I have no idea why it doesn't work for you. Are you sure that the glibc
package user actually HAS a .bash_profile?

root>echo "echo \"This is .bash_profile.\"" >~glibc/.bash_profile
root>cat ~glibc/.bash_profile
echo "This is .bash_profile."
root>echo 'echo $PATH' | su - glibc
/usr/bin:/bin
root> su - glibc
This is .bash_profile.
glibc>



Are you sure you're using the
correct su?

I checked that the version I am using is 5.2.1 from the coreutils package:
root>su --version
su (coreutils) 5.2.1
[...]

Which version is the correct one? Shall I try a newer version of coreutils?

I do not remember why I decided that the problem is in su:

root>echo "echo \"This is .bash_profile.\"" >~glibc/.bash_profile
root>cat ~glibc/.bash_profile
echo "This is .bash_profile."
root>cat ~glibc/.bashrc
source ~/.bash_profile

root>echo 'echo $0' | su glibc
bash

root>echo 'echo $0' | su - glibc
-bash

root>su glibc
This is .bash_profile.
glibc>echo $0
bash
# Shouldn't this be a login shell?!

root>su - glibc
This is .bash_profile.
glibc>echo $0
-bash

root>bash --version
GNU bash, version 3.00.0(1)-release (i686-pc-linux-gnu)
[...]

root>echo 'bash --version' | su glibc
<same result as above>

root>echo 'bash --version' | su - glibc
<same result as above>

--
http://linuxfromscratch.org/mailman/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/lfs/faq.html
Unsubscribe: See the above information page

Reply via email to