X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type; q=dns; s=default; b=m9Zr mQM0E1DQj1702tPDjvJBLG93Bd9GadQwQgfvNabjbf1RFYo0YFQCf7fxX+HlXxxr ocwLcsWX4QgrwqKzpjhO7qsxMCNNcg0u/W0eBVpSqvcziDQvxGMfNKLZfYMCn086 ME3PPlOHZdwhgfwIHWVWJxIwQsLKzAERsPOibnI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type; s=default; bh=F3XBecVF5F 21OOdixXZotQPBRu4=; b=riytEEJM398NtMuA/T+Xa0QsOHXiHmn4mP2zBHDDDE 4jGdj1PtUOz0gE4P6E+mfMUxm5CYcbqCu4OLaNvDsGHDcKA8Gj0VwfVW850Yfhl3 Bt6r1NowWdn6WZySwSwuigkGzewuTs3kPAr6A3fExa2xIGe/9gk0ev4+Fy/Rnd4N I= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS autolearn=no version=3.3.2 spammy=determines X-HELO: mx1.redhat.com Subject: Re: Get Cygwin home directory path for current user To: cygwin AT cygwin DOT com References: <9539a1e8-e893-3175-f96c-fb4ad172702c AT redhat DOT com> From: Eric Blake Openpgp: preference=signencrypt Message-ID: <2a87c6c0-6a0f-6994-3620-8b0b722d7d49@redhat.com> Date: Thu, 14 Feb 2019 15:14:54 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="hT8pUzIfjwsQQQ8RawT5j9ZKgQSAJka30" X-IsSubscribed: yes --hT8pUzIfjwsQQQ8RawT5j9ZKgQSAJka30 Content-Type: multipart/mixed; boundary="TqS3ZWVzw7x42ant2lFEF5Tk51Y4j1EeA"; protected-headers="v1" From: Eric Blake To: cygwin AT cygwin DOT com Message-ID: <2a87c6c0-6a0f-6994-3620-8b0b722d7d49 AT redhat DOT com> Subject: Re: Get Cygwin home directory path for current user References: <9539a1e8-e893-3175-f96c-fb4ad172702c AT redhat DOT com> In-Reply-To: --TqS3ZWVzw7x42ant2lFEF5Tk51Y4j1EeA Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 2/14/19 2:22 PM, Bill Stewart wrote: > On Thu, Feb 14, 2019 at 12:49 PM Eric Blake wrote: >=20 >> 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" >=20 > 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... >=20 > So therefore I can write >=20 > dash -c '/bin/cygpath -w ~' >=20 > To get it, but this seems a bit roundabout and awkward. >=20 > 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) --=20 Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org --TqS3ZWVzw7x42ant2lFEF5Tk51Y4j1EeA-- --hT8pUzIfjwsQQQ8RawT5j9ZKgQSAJka30 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEccLMIrHEYCkn0vOqp6FrSiUnQ2oFAlxl2k4ACgkQp6FrSiUn Q2q/KggAr+cRkdy/hQsE2jKYYnGuHVOWTc1GDfW9Zqm7HwnEbDOS6mH7WKzfPtkh KiC4nIEVI4meXuyYTHw4q6SGjxVSC2PHRUBrVdzune1ckjTdgBHagIdmLVdM902E Uxu6KfKzXOEO8bthVfLB5X2BONWjnpj84rrn2nPz/RR46jtN8X6UUqeB/x6d6wVP 9By5cxx/26PSTyutOgGN8A7+QejFTpJ10ytXXQwS928ga8+t+zhiroUeRyNRcBp4 fEe5uPL00WcVXQMcaG1C+izThO2AyglllEMeOA148YaHb524DtilvxhehtUOTThE BdSk9cg/XSetvwQmuyovSfZiVv1qUA== =+0tF -----END PGP SIGNATURE----- --hT8pUzIfjwsQQQ8RawT5j9ZKgQSAJka30--