[haiku-commits] Re: r38133 - haiku/trunk/src/apps/terminal

  • From: François Revol <revol@xxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 16 Aug 2010 12:30:54 +0200

Le 16 août 2010 à 11:53, Axel Dörfler a écrit :

> pulkomandy <pulkomandy@xxxxxxxxxxxxxxxxx> wrote:
>> On Mon, Aug 16, 2010 at 11:28:42AM +0200, Axel D?rfler wrote:
>>> What's the exact purpose of the --login, anyway?
>> http://www.faqs.org/docs/bashman/bashref_63.html#SEC63
>> 
>> It makes bash read /etc/profile instead of ~/.bashrc .
>> This is specific to bash, so it has likely nothing to do in Terminal.
> 
> If bash is invoked as "sh", it should already do that in order to mimic 
> POSIX requirements - and AFAICT that's what we do.

No.
Running /bin/sh alone doesn't make it a login shell.
Login shells should only be the top-level ones, not the shells started by 
subprocesses, for ex.

The correct way to start a shell from a terminal should be with 
argv[0] = "-theshell".
This indicates it's a login shell (and not a subshell).

For ex here on OSX ps x gives:
 1071 s007  SN+    0:00.68 -bash

Actually OSX Terminal.app does run login -pf $USER to actually let it spawn the 
shell itself. Our /bin/login probably already checks the user shell anyway.

The use of --login actually comes from BeOS being unable to pass argv[0] 
correctly.
Instead R5 copied the absolute path to the launched binary in argv[0].

The workaround in R5 was therefore to pass --login which only works for bash 
and does the same as prepending - to argv[0].

IIRC we fixed this bug in Haiku already so we can probably get away with this 
--login trick, and either use -$SHELL or just /bin/login -pf $USER.

François.

Other related posts: