Path prefix //./ in Cygwin
Sam Edge
sam.edge.cygwin@gmx.com
Thu Jun 12 00:40:42 GMT 2025
On 12/06/2025 00:01, Jeremy Drake via Cygwin wrote:
> While making some tests for a path parser in rust
> (https://github.com/rust-lang/rust/pull/141864), an interesting corner
> case in Cygwin path handling came to light:
>
> Works:
> \\.\C:
> //.\C:
> //./C:\foo
>
> Doesn't work:
> //./C:
> //./C:/foo
>
> It appears to be able to use the \\.\ prefix, there must be at least 1
> backslash in the path. Otherwise, it seems that . and .. are being
> normalized like a normal path and //./C:/foo is treated like
> //C:/foo. The delay attempting to access it makes me think it is looking
> for a server/share style path.
>
> My question is whether this behavior is intentional or a bug. I don't
> want to see rust codify this in their path parser and tests, only to have
> it change later as a bugfix in a corner case of path handling.
>
Cygwin is a POSIX layer. In POSIX //x/y is allowed to mean the same as
/x/y as it does in Linux or it can give special significance to 'x' in
this context.
Cygwin treads a tricky line with backslash. Technically in POSIX it has
no special significance - a backslash is not a path separator and is a
legitimate character for a directory or file name but for convenience
and backwards compatibility sometimes - and others will be able to give
you the circumstances better than I - it will attempt to treat the path
as a Windows one.
I would think that if you're building something against Cygwin, it's
probably best to assume it's POSIX where only forward-slash is special
and not try to second-guess.
Just my two penn'orth.
--
Sam Edge
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_0x8AC2CEBF54528E30.asc
Type: application/pgp-keys
Size: 648 bytes
Desc: OpenPGP public key
URL: <https://cygwin.com/pipermail/cygwin/attachments/20250612/2df4e852/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 236 bytes
Desc: OpenPGP digital signature
URL: <https://cygwin.com/pipermail/cygwin/attachments/20250612/2df4e852/attachment.sig>
More information about the Cygwin
mailing list