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