[gnu.bash.bug] bash seems to execute ".profile" when it shouldn't

tmb@AI.MIT.EDU (Thomas M. Breuel) (09/11/89)

wilde$ # this is /bin/sh running on an HP 9000/350 running HP-UX
wilde$ bash
this was the .profile
wilde$ help|sed 1q
GNU bash, version 1.03.11 (plus HPUX hacks)
wilde$ logout
wilde$

Bash should only execute $HOME/.profile when it is invoked with
argv[0][0]=='-', following the standard UNIX convention.

tmb@AI.MIT.EDU (Thomas M. Breuel) (09/13/89)

	to quote from my locally hacked version of bash 1.03:
	|   /* This is the only way I know how to find an rsh shell.
	|      If this shell is remote (rsh host command), then make
	|      sure that we run the .login stuff so that the user can
	|      set his/her PATH. */

	 It's a feeture. Honest. Feel free to ifdef it out; I do.

If rsh wanted a login shell, it would invoke the shell with a "-" as 
its first argument. For a variety of reasons, rsh doesn't. If that's
the behavior someone wants for rsh, he should change the behavior
of rsh, not of the shell.

The reason why it's a bad idea to make the shell source the .profile
is that (1) .profile's are written with the assumption that they'll
only get executed on login, so they will often change tty modes 
(which gives error output when done from inside rsh) and ask
for user input (like terminal type); (2) someone may just type "bash"
from another non-bash shell and have his .profile executed
(and what about a bash script that is executed by a non-bash user? What
about "bash file"? What about "bash < file"?)

Now, as far as I'm concerned, it would be OK if bash executed
a ".bash_login" file (I would simply not have one of those). However, 
the semantics of the .profile are determined by the Bourne shell, 
and if bash deviates too far from them, it will be impossible to go 
back and forth between the two.

cudcv@warwick.ac.uk (Rob McMahon) (09/15/89)

In article <8909130140.AA03372@wheat-chex> tmb@AI.MIT.EDU (Thomas M. Breuel) writes:
|	to quote from my locally hacked version of bash 1.03:
|	|   /* This is the only way I know how to find an rsh shell.
|	|      If this shell is remote (rsh host command), then make sure that
|	|      we run the .login stuff so that the user can set his/her PATH.
|
|If rsh wanted a login shell, it would invoke the shell with a "-" as 
|its first argument. For a variety of reasons, rsh doesn't. If that's the
|behavior someone wants for rsh, he should change the behavior of rsh, not of
|the shell.

This is vital.  It is quite normal for people to put things in .profile that
produce output.  Anything like this will blow rsh away (it will break the
protocol, since it is not expecting output).  Anything like PATH should be set
in the .bashrc.

Rob
-- 
UUCP:   ...!mcvax!ukc!warwick!cudcv	PHONE:  +44 203 523037
JANET:  cudcv@uk.ac.warwick             ARPA:   cudcv@warwick.ac.uk
Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England