Get Cygwin home directory path for current user

Eric Blake eblake@redhat.com
Thu Feb 14 23:57:00 GMT 2019


On 2/14/19 4:52 PM, Bill Stewart wrote:

> So I guess I have a feature request:
> 
> Add a new flag to cygpath that returns the current user's home
> directory (same as what ~ returns from a Cygwin shell).

Let's phrase that more accurately. You want a new option to cygpath that
would return the value of $HOME that Cygwin would assign. (The fact that
a cygwin shell would expand ~ into the contents of $HOME is a side
point; if you can access the correct $HOME, then you don't need a cygwin
shell to tilde-expand ~ into $HOME).

But wait - let's see how Cygwin assigns $HOME in the first place:

https://cygwin.com/faq.html#faq.setup.home

If $HOME is set in your Windows environment, then that's the $HOME that
Cygwin will use.  In which case, 'cygpath -aw $HOME' from PowerShell
should return the same thing as 'dash -c 'cygpath -aw $HOME'' from
PowerShell.

But if $HOME is not set in your Windows environment, then you have a
point that any Cygwin process will see HOME set to whatever 'getent
passwd' would display, while PowerShell would not see a $HOME variable
set at all. So you DO have a point that an additional option to cygpath
to compute and display $HOME may be useful.

Are you going to write and submit the patch?  Because it's not my itch,
I do not plan to be the one to write such a patch.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://cygwin.com/pipermail/cygwin/attachments/20190214/9d7cf999/attachment.sig>


More information about the Cygwin mailing list