delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/06/05/22:36:39

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Message-ID: <4848A716.5010200@cygwin.com>
Date: Thu, 05 Jun 2008 22:55:18 -0400
From: "Larry Hall (Cygwin)" <reply-to-list-only-lh AT cygwin DOT com>
Reply-To: cygwin AT cygwin DOT com
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.3) Gecko/20070505 Remi/2.0.0.0-3.fc4.remi Lightning/0.8 Thunderbird/2.0.0.0 Mnenhy/0.7.5.0
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: how can I stop Windows setting HOME?
References: <17682731 DOT post AT talk DOT nabble DOT com> <dd3cefac0806051822i3dc7b4d2pf943f33335b29cb3 AT mail DOT gmail DOT com> <dd3cefac0806051842l650b7657u5f0ae0e696cce0bf AT mail DOT gmail DOT com>
In-Reply-To: <dd3cefac0806051842l650b7657u5f0ae0e696cce0bf@mail.gmail.com>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Adam Thompson wrote:
> 2008/6/6 Adam Thompson <adwulf AT gmail DOT com>:
>> 2008/6/6 anadem <anadem AT gmail DOT com>:
>>> Is there any way to permanently unset the HOME env-var in Windows? I could
>>> run a batch file at startup but afaik that would not be a systemwide removal
>>> of HOME.
>>>
>> I do not think this is a Windows issue.
>>
> 
> Further to this, a quick google reveals:
> 
> "The HOME environment variable is used by UNIX shells to determine the
> location of your home directory. This environment variable is
> converted from the Microsoft Windows format (that is, C:\home\bob) to
> UNIX format (that is, /home/bob) when a Cygwin process first starts.
> To prevent confusion, ensure that HOME and /etc/passwd agree on your
> home directory."
> 
> http://www.redhat.com/docs/manuals/gnupro/GNUPro-Toolkit-03r1/gnupro_8.html
> 
> So, it would seem that Cygwin takes the value of (correct me here):
> 
> %HOMEDRIVE% + %HOMEPATH%
> 
> or more likely (and reliably - remember %HOMESHARE%):
> 
> %USERPROFILE%
> 
> And imports it to $HOME
> 
> Depending on how you launch cygwin, you may be able to start it with a
> script or .pif that sets these variables to what you require.
> 
> See: http://www.cygwin.com/faq/faq.setup.html#faq.setup.home - which
> suggests that HOMEDRIVE and HOMEPATH are used instead of USERPROFILE.
> 

Generally speaking, you're right that Windows doesn't set HOME but
rather HOMEDRIVE and HOMEPATH.  If HOME is getting set in the Windows
environment, something else that's installed is setting it and Cygwin
is just going along with it because it's set in the environment.  If
it is not possible to figure out what is setting HOME for Windows, you
can unset it in cygwin.bat, or whatever mechanism Cygwin is started
with, as you noted.  But it would be better to find the source and
squash it.  And although you pointed at the right FAQ entry describing
the hierarchy of rules used for setting HOME within Cygwin's environment,
your interpretation is a bit off.  As the FAQ states, HOME is determined
by one of the following in order of decreasing priority:

    1. HOME from the Windows environment, translated to POSIX form.
    2. The entry in /etc/passwd
    3. HOMEDRIVE and HOMEPATH from the Windows environment
    4. /

Once one of these rules is fulfilled, the remainder are skipped.  So
if HOME is set in the Windows environment, Cygwin will use that (converted
to POSIX form).  If it's not and there's an '/etc/passwd' file with an entry
for the current user, the home path specified there will be used. Otherwise,
HOMEDRIVE and HOMEPATH will be used to define HOME in CYGWIN (again,
converted to POSIX form).  And, if for some reason none of these other
rules fire, HOME is set to '/'.

It is highly recommended that one let rule #2 fire, since '/etc/passwd' is
the source of the home path used by Cygwin's telnet, ssh, etc.  Consistency
between these utilities and your default Cygwin shell/environment is
very likely to eliminate future brain strains. ;-)


-- 
Larry Hall                              http://www.rfk.com
RFK Partners, Inc.                      (508) 893-9779 - RFK Office
216 Dalton Rd.                          (508) 893-9889 - FAX
Holliston, MA 01746

_____________________________________________________________________

A: Yes.
 > Q: Are you sure?
 >> A: Because it reverses the logical flow of conversation.
 >>> Q: Why is top posting annoying in email?

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019