This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Get Cygwin home directory path for current user


On Fri, Feb 15, 2019 at 9:14 AM Takashi Yano wrote:

> If you don't want to use "shell", you can:
> c:/cygwin/bin/cygpath -w $(c:/cygwin/bin/getent passwd $env:USERNAME | c:/cygwin/bin/cut -d: -f6)
> but I'm not sure if you think this is "awkward" as well.

Why cut if you are already using PowerShell? All you need is

cygpath -w ((getent passwd $Env:USERNAME) -split ':')[5]

We're still forced to spawn two executables, but at least we're not
dependent on a Cygwin shell expansion so this is probably a bit
better.

Regards,

Bill

--
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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]