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: List-Subscribe: List-Archive: List-Post: List-Help: , 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 User-Agent: Thunderbird MIME-Version: 1.0 To: Vince Rice , Bill Stewart CC: "cygwin AT cygwin DOT com" Subject: Re: Get Cygwin home directory path for current user References: <9539a1e8-e893-3175-f96c-fb4ad172702c AT redhat DOT com> <2a87c6c0-6a0f-6994-3620-8b0b722d7d49 AT redhat DOT com> <06CBB893-FD9F-460F-B00C-E22950036B5E AT solidrocksystems DOT com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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: 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