public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: cygwin@cygwin.com
Subject: Re: Get Cygwin home directory path for current user
Date: Thu, 14 Feb 2019 21:51:00 -0000	[thread overview]
Message-ID: <2a87c6c0-6a0f-6994-3620-8b0b722d7d49@redhat.com> (raw)
In-Reply-To: <CANV9t=R-1XE-cyKa5vtvtu_3dJiYoLRstBTN86JiQ2FS2T+Jyw@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 1344 bytes --]

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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2019-02-14 21:14 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-14 19:49 Bill Stewart
2019-02-14 20:23 ` Eric Blake
2019-02-14 20:48   ` Bill Stewart
2019-02-14 21:51     ` Eric Blake [this message]
2019-02-14 22:14       ` Bill Stewart
2019-02-14 22:52         ` Vince Rice
2019-02-14 23:31           ` Bill Stewart
2019-02-14 23:41             ` Vince Rice
2019-02-14 23:47               ` Bill Stewart
2019-02-15  0:03                 ` Vince Rice
2019-02-15  1:25                   ` Bill Stewart
2019-02-15 17:10                     ` Brian Inglis
2019-02-16  8:19                   ` L A Walsh
2019-02-19 16:43                     ` Bill Stewart
2019-02-15  7:57                 ` LRN
2019-02-15 16:38                 ` Takashi Yano
2019-02-15 19:34                   ` Bill Stewart
2019-02-14 23:57             ` Eric Blake
2019-02-15 12:03             ` Andrey Repin
2019-02-15 20:17               ` Bill Stewart
2019-02-15 20:37                 ` Andrey Repin
2019-02-15 22:48                   ` Doug Henderson
2019-02-16  1:05                     ` Andrey Repin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2a87c6c0-6a0f-6994-3620-8b0b722d7d49@redhat.com \
    --to=eblake@redhat.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).