Re: Get Cygwin home directory path for current user

2019-02-19 Thread Bill Stewart
On Fri, Feb 15, 2019 at 11:09 PM L A Walsh wrote:

> Vince, I think What Bill is trying to ask is how does
> the cygwin shell might do it (answer: look at the source! ;-)).

Or rather more succinctly: "Cygwin, what is the path to the current
user's home directory?"

IMO it would be simpler for cygpath to have a flag for this so we can
simply ask directly instead of collecting stdout from a shell command.

But as I noted - requesting it from a shell _does_ work - my thought
is simply that this would be a rather useful option to have in
cygpath.

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



Re: Get Cygwin home directory path for current user

2019-02-15 Thread L A Walsh
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



Re: Get Cygwin home directory path for current user

2019-02-15 Thread Andrey Repin
Greetings, Doug Henderson!

>>
>> Greetings, Bill Stewart!
>>
>> >> Setup your system to use %USERPROFILE% as $HOME and forget this problem
>> >> altogether.
>> >> For interoperability's sake! (q)
>>
>> > That won't work, because Cygwin $HOME can be different from the
>> > USERPROFILE environment variable on Windows.
>>
>> Make. It. The. Same.
>> Tell, don't ask.
>>
> NO NO NO.

> I do not mix Windows and cygwin.

Are you Bill Stewart? No? Then what you are trying to say here?
It is he was arguing "for interoperability".

P.S.
Also, please teach your mail user agent to not quote raw email addresses.


-- 
With best regards,
Andrey Repin
Saturday, February 16, 2019 3:54:35

Sorry for my terrible english...


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



Re: Get Cygwin home directory path for current user

2019-02-15 Thread Doug Henderson
On Fri, 15 Feb 2019 at 13:35, Andrey Repin  wrote:
>
> Greetings, Bill Stewart!
>
> >> Setup your system to use %USERPROFILE% as $HOME and forget this problem
> >> altogether.
> >> For interoperability's sake! (q)
>
> > That won't work, because Cygwin $HOME can be different from the
> > USERPROFILE environment variable on Windows.
>
> Make. It. The. Same.
> Tell, don't ask.
>
NO NO NO.

I do not mix Windows and cygwin. I always use the CYGWIN_NOWINPATH=1
to isolate Windows from cygwin. I do not want to accidently run a
cygwin binary when I am using Windows, nor a Windows binary when using
cygwn.

For mixed operations, I use MINGW64. Look at what GitHub does with
their Github Desktop product. The MINGW64 package is included, and it
provides many of the same packages as cygwin, but they are build to
interoperate with the Windows environment, i.e. they recognize both
windows and unix format filenames, and transparently convert as
necessary.

When I need to use unix utilities from the windows environment, I
configure the MINGW64 binary paths at the start of the PATH variable.
It is just too much work to make cygwin binaries work in isolation.

In my option, the cygwin and Windows home directories should always be
different locations. However, the MINGW64 and the Windows directories
can be the same location.

Doug

-- 
Doug Henderson, Calgary, Alberta, Canada - from gmail.com

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



Re: Get Cygwin home directory path for current user

2019-02-15 Thread Andrey Repin
Greetings, Bill Stewart!

>> Setup your system to use %USERPROFILE% as $HOME and forget this problem
>> altogether.
>> For interoperability's sake! (q)

> That won't work, because Cygwin $HOME can be different from the
> USERPROFILE environment variable on Windows.

Make. It. The. Same.
Tell, don't ask.


-- 
With best regards,
Andrey Repin
Friday, February 15, 2019 23:32:07

Sorry for my terrible english...


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



Re: Get Cygwin home directory path for current user

2019-02-15 Thread Bill Stewart
On Fri, Feb 15, 2019 at 4:50 AM Andrey Repin wrote:

> Not as good as bash. Just so you know.

We'll just agree to disagree on that (particularly on Windows).

> Setup your system to use %USERPROFILE% as $HOME and forget this problem
> altogether.
> For interoperability's sake! (q)

That won't work, because Cygwin $HOME can be different from the
USERPROFILE environment variable on Windows.

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



Re: Get Cygwin home directory path for current user

2019-02-15 Thread Bill Stewart
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



Re: Get Cygwin home directory path for current user

2019-02-15 Thread Brian Inglis
On 2019-02-14 17:03, Bill Stewart wrote:
> On Thu, Feb 14, 2019 at 4:57 PM Vince Rice wrote:
>> Here, you say "forget about the ~ character." We can't "forget" about the 
>> tilde. This whole
>> conversation is about the tilde, specifically tilde expansion.
> Eric Blake seems to have understood (see his response if it's still unclear).
- /home/$LOGNAME
- getent passwd $LOGNAME has Cygwin home /home/$LOGNAME as 2nd last field
- $HOMEDRIVE$HOMEPATH
- $USERPROFILE
- FOLDERID_Profile seems to be 40 on Win10 so cygpath -F 40 gives my USERPROFILE

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.

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



Re: Get Cygwin home directory path for current user

2019-02-15 Thread Takashi Yano
On Thu, 14 Feb 2019 16:41:11 -0700 Bill Stewart wrote:
> (?) 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.)

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.

-- 
Takashi Yano 

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



Re: Get Cygwin home directory path for current user

2019-02-15 Thread Andrey Repin
Greetings, Bill Stewart!

>> There is -- use a cygwin shell. As Eric has already explained, expansion is 
>> the
>> shell's responsibility. Powershell doesn't do it. If you want expansion, use 
>> one
>> that does.

> So let's consider, for a bit, that not everybody uses a Cygwin shell.
> (Hard to believe, perhaps, but PowerShell is really quite good.)

Not as good as bash. Just so you know.

> For interoperability's sake, it is useful to get this path from the
> Windows side, and this seems oddly absent.

Setup your system to use %USERPROFILE% as $HOME and forget this problem
altogether.
For interoperability's sake! (q)

> Cygpath already has a set of flags for returning system information
> directories, such as -H, which returns the path to the user profile
> directory. (As I noted previously, this is not always the same as ~
> when expanded in a Cygwin shell.)

Cygpath is designed to increse Cygwin's interoperability. Not PS's or what
not.

> Ergo: It would be quite useful if cygpath could tell us this path directly.

> As I noted previously, yes, the below works:

> dash -c '/bin/cygpath -aw ~'

> However, this seems awkward and requires a Cygwin shell (why should
> that be a prerequisite?).

Try http://make-everything-ok.com/ then.

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


-- 
With best regards,
Andrey Repin
Friday, February 15, 2019 14:29:47

Sorry for my terrible english...


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



Re: Get Cygwin home directory path for current user

2019-02-14 Thread LRN
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.



signature.asc
Description: OpenPGP digital signature


Re: Get Cygwin home directory path for current user

2019-02-14 Thread Bill Stewart
On Thu, Feb 14, 2019 at 4:57 PM Vince Rice wrote:

> Here, you say "forget about the ~ character." We can't "forget" about the 
> tilde. This whole
> conversation is about the tilde, specifically tilde expansion.

Eric Blake seems to have understood (see his response if it's still unclear).

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



Re: Get Cygwin home directory path for current user

2019-02-14 Thread Vince Rice
> On Feb 14, 2019, at 5:41 PM, 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.)

It would not appear that you do. You asked why a Cygwin shell would be a 
prerequisite.
That's exactly why a Cygwin shell is a prerequisite—*because it's the Cygwin 
shell that
does the expansion.* The only way to get the expansion is through a Cygwin 
shell.

Here, you say "forget about the ~ character." We can't "forget" about the 
tilde. This whole
conversation is about the tilde, specifically tilde expansion.

You're not going to get tilde expansion outside of a Cygwin shell.
*Because it's the Cygwin shell that does the expansion.*
--
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



Re: Get Cygwin home directory path for current user

2019-02-14 Thread Eric Blake
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



signature.asc
Description: OpenPGP digital signature


Re: Get Cygwin home directory path for current user

2019-02-14 Thread Bill Stewart
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.)

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



Re: Get Cygwin home directory path for current user

2019-02-14 Thread Vince Rice
> On Feb 14, 2019, at 4:52 PM, Bill Stewart  wrote:
> 
> On Thu, Feb 14, 2019 at 3:14 PM Vince Rice wrote:
> 
>> There is -- use a cygwin shell. As Eric has already explained, expansion is 
>> the
>> shell's responsibility. Powershell doesn't do it. If you want expansion, use 
>> one
>> that does.
> 
> So let's consider, for a bit, that not everybody uses a Cygwin shell.
> (Hard to believe, perhaps, but PowerShell is really quite good.)
I didn't suggest everyone did. But people who want tilde expansion do, because 
it's
the shell that is responsible for tilde expansion.

> For interoperability's sake, it is useful to get this path from the
> Windows side, and this seems oddly absent.
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.

> Cygpath already has a set of flags for returning system information
> directories, such as -H, which returns the path to the user profile
> directory. (As I noted previously, this is not always the same as ~
> when expanded in a Cygwin shell.)
Those "system information directories" are *Windows* directories. Completely 
different
thing.

> As I noted previously, yes, the below works:
> 
> dash -c '/bin/cygpath -aw ~'
> 
> However, this seems awkward and requires a Cygwin shell (why should
> that be a prerequisite?).
Because, repeat after me, IT'S THE SHELL THAT DOES THE EXPANSION!
--
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



Re: Get Cygwin home directory path for current user

2019-02-14 Thread Bill Stewart
On Thu, Feb 14, 2019 at 3:14 PM Vince Rice wrote:

> There is -- use a cygwin shell. As Eric has already explained, expansion is 
> the
> shell's responsibility. Powershell doesn't do it. If you want expansion, use 
> one
> that does.

So let's consider, for a bit, that not everybody uses a Cygwin shell.
(Hard to believe, perhaps, but PowerShell is really quite good.)

For interoperability's sake, it is useful to get this path from the
Windows side, and this seems oddly absent.

Cygpath already has a set of flags for returning system information
directories, such as -H, which returns the path to the user profile
directory. (As I noted previously, this is not always the same as ~
when expanded in a Cygwin shell.)

Ergo: It would be quite useful if cygpath could tell us this path directly.

As I noted previously, yes, the below works:

dash -c '/bin/cygpath -aw ~'

However, this seems awkward and requires a Cygwin shell (why should
that be a prerequisite?).

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

Thanks!

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



Re: Get Cygwin home directory path for current user

2019-02-14 Thread Vince Rice
> On Feb 14, 2019, at 3:51 PM, Bill Stewart wrote:
> 
> Seems like there must be a better way...

There is — use a cygwin shell. As Eric has already explained, expansion is the
shell's responsibility. Powershell doesn't do it. If you want expansion, use one
that does.
--
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



Re: Get Cygwin home directory path for current user

2019-02-14 Thread Bill Stewart
On Thu, Feb 14, 2019 at 2:15 PM Eric Blake wrote:

> If you want tilde-expansion to happen, you have to use a shell that does
> tilde-expansion. bash and dash do, PowerShell does not.  It is not
> cygpath's fault, but your choice of shell, that determines whether ~ is
> expanded.  And, since the tilde-expansion of ~ is $HOME, and PowerShell
> _does_ support $HOME, use $HOME instead of relying on tilde-expansion.
> (The expansion of ~user is a much harder nut to crack - for that, you
> really do depend on a shell doing proper tilde-expansion, as there are
> no easy shortcuts)

The only problem with that is that PowerShell $HOME is not always
equivalent to Cygwin ~ .

For example, if the Windows user has a home drive and directory
specified in the profile, Cygwin ~ will point there rather than
PowerShell $HOME (which points at the user's profile directory).

I can make do with /bin/dash -c 'cygpath -aw ~' - from the Windows
side, but this makes me spawn two executables and seems like
unnecessary overhead.

Seems like there must be a better way...

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



Re: Get Cygwin home directory path for current user

2019-02-14 Thread Eric Blake
On 2/14/19 2:22 PM, Bill Stewart wrote:
> On Thu, Feb 14, 2019 at 12:49 PM Eric Blake wrote:
> 
>> Depending on the shell, ~ is expanded to $HOME prior to invoking a
>> program. But if you want to take the shell's expansions out of the
>> equation, you could use:
>>
>> cygpath -w "$HOME"
> 
> Ah. I'm not using a Cygwin shell (PowerShell actually). So the
> expansion happens before cygpath sees it, which is why it works in a
> Cygwin shell but not directly from Windows...
> 
> So therefore I can write
> 
> dash -c '/bin/cygpath -w ~'
> 
> To get it, but this seems a bit roundabout and awkward.
> 
> Is there any way to do it more directly from a Windows shell?

If you want tilde-expansion to happen, you have to use a shell that does
tilde-expansion. bash and dash do, PowerShell does not.  It is not
cygpath's fault, but your choice of shell, that determines whether ~ is
expanded.  And, since the tilde-expansion of ~ is $HOME, and PowerShell
_does_ support $HOME, use $HOME instead of relying on tilde-expansion.
(The expansion of ~user is a much harder nut to crack - for that, you
really do depend on a shell doing proper tilde-expansion, as there are
no easy shortcuts)

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



signature.asc
Description: OpenPGP digital signature


Re: Get Cygwin home directory path for current user

2019-02-14 Thread Bill Stewart
On Thu, Feb 14, 2019 at 12:49 PM Eric Blake wrote:

> Depending on the shell, ~ is expanded to $HOME prior to invoking a
> program. But if you want to take the shell's expansions out of the
> equation, you could use:
>
> cygpath -w "$HOME"

Ah. I'm not using a Cygwin shell (PowerShell actually). So the
expansion happens before cygpath sees it, which is why it works in a
Cygwin shell but not directly from Windows...

So therefore I can write

dash -c '/bin/cygpath -w ~'

To get it, but this seems a bit roundabout and awkward.

Is there any way to do it more directly from a Windows shell?

Thanks!

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



Re: Get Cygwin home directory path for current user

2019-02-14 Thread Eric Blake
On 2/14/19 1:40 PM, Bill Stewart wrote:
> According to this:
> 
> https://stackoverflow.com/questions/42841907/
> 
> cygpath -w ~
> 
> ...formerly produced to stdout the home directory path for the current user.
> 
> This seems not be the case any more: When I run cygpath -w ~, I get just ~.

What shell are you using?

> 
> Is this by design? If so, what's the way to programmatically determine
> the Windows path of ~?

Depending on the shell, ~ is expanded to $HOME prior to invoking a
program. But if you want to take the shell's expansions out of the
equation, you could use:

cygpath -w "$HOME"

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



signature.asc
Description: OpenPGP digital signature


Get Cygwin home directory path for current user

2019-02-14 Thread Bill Stewart
According to this:

https://stackoverflow.com/questions/42841907/

cygpath -w ~

...formerly produced to stdout the home directory path for the current user.

This seems not be the case any more: When I run cygpath -w ~, I get just ~.

Is this by design? If so, what's the way to programmatically determine
the Windows path of ~?

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