delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
DomainKey-Signature: | a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:message-id:date:from:mime-version:to:cc | |
:subject:references:in-reply-to:content-type | |
:content-transfer-encoding; q=dns; s=default; b=xUnHX/ctFP/e8MFC | |
6bh9bz7fYyZHVpXR8bbhMpVrvQhyHyMuWvLFeL/fNj8dqQXPeFFYFvOS+CZiBzHQ | |
uxxxD85iWC6wXDEkTsa/Rsu20omjIxuHYtlW9v84ts/mKDe7OKFXBIv2yqcrDXWR | |
5DBVc+FWhDqk1kmhJ+auGmbg3yY= | |
DKIM-Signature: | v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:message-id:date:from:mime-version:to:cc | |
:subject:references:in-reply-to:content-type | |
:content-transfer-encoding; s=default; bh=Uz6mFRxT33Y3ja4dFOa+PN | |
Wk++Q=; b=Uk8BCzl03i2gXug9og0cvFfU0O2ytVma4CHO+fV9LYZa4wbUBYWK0y | |
ueq+vMF641uP6NF0ng1OHW2u6KJQEDT4UNCt+3HdAae7qYuDUn8e0oAXaSKBIITJ | |
YYgKXIG2N7GLe3R1gzv9W/RWf3lE6t0eIiO+OvfQ5ZWyhj8fvMAHU= | |
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 |
Authentication-Results: | sourceware.org; auth=none |
X-Spam-SWARE-Status: | No, score=-6.9 required=5.0 tests=BAYES_00,GIT_PATCH_2 autolearn=ham version=3.3.2 spammy=webpage, rightly, nis, H*r:8.14.4 |
X-HELO: | Ishtar.sc.tlinx.org |
Message-ID: | <5C67A90A.50704@tlinx.org> |
Date: | Fri, 15 Feb 2019 22:09:14 -0800 |
From: | L A Walsh <cygwin AT tlinx DOT org> |
User-Agent: | Thunderbird |
MIME-Version: | 1.0 |
To: | Vince Rice <vrice AT solidrocksystems DOT com>, Bill Stewart <bstewart AT iname DOT com> |
CC: | "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com> |
Subject: | Re: Get Cygwin home directory path for current user |
References: | <CANV9t=R83dQddZOVWVUg55t7K=DUyE8BiQ10Pn1v4G+xcgPh3w AT mail DOT gmail DOT com> <9539a1e8-e893-3175-f96c-fb4ad172702c AT redhat DOT com> <CANV9t=R-1XE-cyKa5vtvtu_3dJiYoLRstBTN86JiQ2FS2T+Jyw AT mail DOT gmail DOT com> <2a87c6c0-6a0f-6994-3620-8b0b722d7d49 AT redhat DOT com> <CANV9t=QXVTGF0uS+vNCmkrxNOV7GVAsO_5hTS9hizX0tnW=-PA AT mail DOT gmail DOT com> <06CBB893-FD9F-460F-B00C-E22950036B5E AT solidrocksystems DOT com> <CANV9t=RML1q=ZAQOadvrsjmWn2391s6jr_t1MgbaJxO6DM2V5Q AT mail DOT gmail DOT com> <EE1F333E-3A36-40CE-971B-1791145D29CC AT solidrocksystems DOT com> <CANV9t=Td7_G-Bk2XVyBVY3rN1QorgLsGU1ChBtJHOV7-qZVFcA AT mail DOT gmail DOT com> <BC6C185E-45C5-4C23-A82A-6C9A6EA4B063 AT solidrocksystems DOT com> |
In-Reply-To: | <BC6C185E-45C5-4C23-A82A-6C9A6EA4B063@solidrocksystems.com> |
X-IsSubscribed: | yes |
On 2/14/2019 3:57 PM, Vince Rice wrote: >> On Feb 14, 2019, at 5:41 PM, Bill Stewart wrote: >> >> (?) I understand that the shell does ~ expansion.... >> > > It would not appear that you do. You asked why a Cygwin shell would be a prerequisite. > ---- Vince, I think What Bill is trying to ask is how does the cygwin shell might do it (answer: look at the source! ;-)). Bill, I may not be able to say w/certainty, and Brian Inglis's post show various linux + Windows ways of getting it. In the absence of some language, I used something like: $home = $ENV{HOME} || $ENV{USERPROFILE} || $ENV{HOMEDRIVE}.$ENV{HOMEPATH}; A little bit of programming, like in perl would find it: perl -e 'printf "home=%s\n", getpwnam($ENV{USER});' The perl docs tell you the "get" calls mirror the C calls. Likely a shell written in 'C' uses one of those calls. Unfortunately, its not just as simple as checking /etc/passwd these days (though it seems that is what the call is doing) -- various user-management systems do it different ways...like NIS/YP (NetworkInformationSystems/YellowPages) on linux or AD(Active Directory) on Windows, which was derived from MIT's Kerberos. Notice on cygwin (or linux) the file /etc/nsswitch.conf, which says: # This file is read once by the first process in a Cygwin process tree. # To pick up changes, restart all Cygwin processes. For a description # see https://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-mapping-nsswitch # # Defaults: # passwd: files db # group: files db # db_enum: cache builtin # db_home: /home/%U ;<<-- cygwin's default that shell will return # db_shell: /bin/bash # db_gecos: <empty> In this case it looks like the answer to your question, BY DEFAULT, is to use the string /home/%U, where %U = your windows username. Now you can go read the webpage if you want more info, but hopefully this answers at least a bit of your question? When addressing technical people, you need to know how to ask the right (or rightly phrased) questions. Also note, that most of the 'standard answers appear not to apply' in cygwin -- just tack '/home/ on the front of your username. -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |