stat() and tilde prefix (was bad bash tab completion)

Corinna Vinschen
Thu Feb 7 16:24:00 GMT 2013

On Feb  7 17:10, Thomas Wolff wrote:
> Am 07.02.2013 16:30, schrieb Eric Blake:
> >...
> >
> >...
> >the fact that cygwin's handling of .. is not POSIX-compliant.  I think a
> >better fix would be to change file_exists() itself instead of adding a
> >misnamed wrapper function; then bashline.c wouldn't even need patching.
> >  The string 'tilde' need not even be in the patch; what you are really
> >after is a function that says that if '..' is found within a string
> >being probed for existence, then add an additional check to see if the
> >prefix of that string exists as a directory.
> >
> >But I don't mind experimenting with the idea - it remains to be seen
> >whether people will complain that bash is noticeably slower because it
> >takes time to double-check instead of rely on cygwin's non-POSIX
> >shortcut.  And the slowdown would only be on paths containing a '..'; I
> >would NOT be checking for symlinks (even though symlinks containing ..
> >are also being interpreted in a non-POSIX manner, it is much more
> >expensive to second-guess if you have to check every name for being a
> >symlink than it is to just check for literal ..).
> Do I interpret correctly that you talk about bash filename completion here?
> Referring to,
> I'd like to point out that while this ".." thing is a cygwin bug, or
> known downside as Corinna says,
> the same issue occurs on Linux precisely with filename completion
> which isn't consistent there either.
> So it would be "over-fixing" to handle that specifically in bash.
> On the other hand, considering again this "downside":
> If the core cygwin filesystem function would follow this approach,
> simply checking for an occurrence of ".." first before resolving the
> filename,
> wouldn't that be an acceptable fix without inappropriate penalty?

You don't know what you're asking for (can of worms, etc.)

This is some kind of chicken egg problem.

- The path must be normalized, otherwise we can't reliably convert
  the POSIX path prefix to a Windows pathname.

- Only after converting to a Windows path, we can perform file checks.

- Rinse and repeat.

Also, the path normalization is performed in an entirely distinct
function from the mount point conversion, and this in turn is another
function than the path function handling symlinks and devices.
Changing that requires to implement the path conversion functionality
almost from scratch.  Given the age of some of these functions, I'd
like to have done that for a long time, but I'm constantly shying away
since I don't want to break what is working today.  There's, of course,
still the aforementioned chicken-egg problem.


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Problem reports:
Unsubscribe info:

More information about the Cygwin mailing list