cygpath -m behaviour change
Eric Blake
eblake@redhat.com
Wed Sep 18 15:26:00 GMT 2013
On 09/18/2013 08:34 AM, David Griffiths wrote:
> Hi, the script is attempting to determine the directory in which it
> exists, so CURRENT_DIR is a bit misleading. This is so that it can
> access other files in the same package relative to it (quite a common
> technique I think).
>
> Might be helpful to have some examples:
>
> /home/dgriff> mkdir test
> /home/dgriff> cd test
> /home/dgriff/test> cygpath -m "file\.."
> ./
Using \ means you are asking Windows to do the resolution, and Windows
has a known issue that it is intentionally NOT posix-compliant unless
you tweak a registry option. But the fact that you can tweak a registry
option means that you CAN encounter machines where file\.. will fail to
resolve instead of (incorrectly optimizing) to . without first checking
whether "file/" is a directory.
> /home/dgriff/test> cygpath -m "file/.."
> cygpath: error converting "file/.." - No such file or directory
This is POSIX-mandated behavior, and since you used /, you asked for
POSIX semantics. This is not a bug.
>
> Note that the backslash variant always works and all of these used to
> work under previous levels of cygwin.
The backslash variants "work" only so far as the windows registry
setting has not been tweaked to allow windows to use its non-posix
"optimization".
But why are you even using cygpath to try and determine the containing
directory? 'dirname' does that task, in a much more portable manner,
and without having to worry about whether 'file/..' can be abused in
spite of POSIX semantics.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://cygwin.com/pipermail/cygwin/attachments/20130918/b4307fbf/attachment.sig>
More information about the Cygwin
mailing list