Get Cygwin home directory path for current user

LRN lrn1986@gmail.com
Fri Feb 15 07:57:00 GMT 2019


On 15.02.2019 2:41, Bill Stewart wrote:
> On Thu, Feb 14, 2019 at 4:32 PM Vince Rice wrote:
> 
>> I didn't suggest everyone did. But people who want tilde expansion do, because it's
>> the shell that is responsible for tilde expansion.
>> ...
>> No, it isn't "oddly" absent. As has been said repeatedly in this thread, tilde expansion
>> is the responsibility of the shell. Cygwin has nothing to do with it. The *shell* does
>> it.
>> ...
>> Because, repeat after me, IT'S THE SHELL THAT DOES THE EXPANSION!
> 
> (?) I understand that the shell does ~ expansion. I am asking for a
> way to get that particular path (forget about the ~ character for the
> time being) without needing to invoke a Cygwin shell in the first
> place. (That was the whole point of the request.)

This is not *exactly* without invoking Cygwin shell, but i don't see how the
difference matters:

c:/cygwin/bin/bash.exe --login -c "cygpath -w ~"
or
c:/cygwin/bin/bash.exe -c "/bin/cygpath -w ~"

either would work.

If you don't want to hardcode c:/cygwin, use registry functions to grab the
contents of Computer\HKEY_CURRENT_USER\Software\Cygwin\Installations somehow. I
don't know PowerShell, but with reg.exe that would be:

reg query HKEY_CURRENT_USER\Software\Cygwin\Installations

and then you'd have to filter out one of the installations out of that.

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


More information about the Cygwin mailing list