Web lists-archives.com

[Mingw-msys] Re: Re: Re: Is there a MinGW winapi macro defined?




On 18 July 2010 20:49, Cesar Strauss wrote:
> On 17/7/2010 15:28, Andy Koppe wrote:
>> Mintty needs to know the user's home directory to be able to
>> load/store its settings from/to ~/.minttyrc. HOME is set in
>> /etc/profile,  but unfortunately that's too late for mintty, since of
>> course the profile is only sourced by the shell invoked by mintty.
>> Therefore, if HOME isn't set, mintty assumes that the user's home
>> directory is at /home/<loginname>, whereby the login name is obtained
>> through getlogin(). Is that reasonable?
>
> I see the problem. Maybe parse the output of
>
> /bin/sh -l -c "echo $HOME"?
>
> Or maybe start mintty from bash with a shortcut like:
>
> sh -l -c "/bin/mintty&"

Thanks very much for looking at this. Those are good ideas, but they
do have their drawbacks. Common to both is that the startup scripts
end up being executed twice, so any side effects they might have would
happen twice and the startup time would double. (Of course it depends
on the scripts' content whether either of these matter.) Additionally,
the first approach would add a fair bit of complexity and hence scope
for things to go wrong to mintty's startup, while the second would pop
up an additional console window when invoking the outer shell.

Therefore I think I'll stick with the HOME=/home/<loginname>
assumption, which should be correct for the majority of users who use
the default MSYS setup. Others will have to either set HOME before
mintty is invoked or explicitly tell mintty where to store its config
using the --config option. I've added an error message for when the
options can't be saved, to make any problems obvious.


>> Futhermore, I noticed that it makes a difference how bash is told to
>> act as a login shell. From the bash manual: "A login shell is one
>> whose first character of argument zero is  a -, or one started with
>> the --login option." If invoked with the --login option, things behave
>> as expected and HOME ends up being set to /home/$LOGNAME by
>> /etc/profile. Yet if it's invoked with argv[0] set to "-bash", HOME is
>> set to / (i.e. the root directory) before /etc/profile is sourced.
>> This can be seen by going to the MSYS bin directory in a cmd prompt
>> and running 'rxvt -ls', or by copying bash to '-bash' and invoking
>> that. Any idea why this happens?
>
> I can reproduce it. No idea yet why this happens.
>
>> Same thing would happen with mintty if invoked with 'mintty -' (which
>> in the same way as rxvt's -ls option prepends a '-' to the user's
>> default shell), except that I've added a hack that sets HOME to
>> /home/<loginname> if it's not already set. But on second thoughts,
>> mintty shouldn't really be doing that. So should I remove that hack?
>
> I guess it could interfere with local customizations.

Yep, I've now removed that hack. I'll do a beta2 later this week.

Thanks,
Andy

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Mingw-msys mailing list
Mingw-msys@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/mingw-msys