Web lists-archives.com

Re: Get Cygwin home directory path for current user

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:


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

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

Attachment: signature.asc
Description: OpenPGP digital signature