Saturday, April 29, 2023

Re: surprising glob() result on Windows

> Briefly, I have a case where glob("*.ext") returns more files than I
> expect.
>
> To give an example, in a directory of your choice create two files named
> "test.any" and "zest.anyother". The important detail is that the second
> filename's extension be prefixed by the first filename's extension.
>
> Then launch Vim in that directory and run the command
> :echo glob("*.any")
> Both files are returned, not just "test.any".
>
> I see this on Windows running vim 9.0.1240 with normal features built
> with Visual C. On the other hand, Vim on my linux box returns only
> "test.any", as I would expect, so I don't think this a feature. :)
>
> Any comments?

What file system is being used? Some older filesystems use a trick to
make long file names possible. The file then appears twice in the
directory, once with the short name and once with the long name. Vim
may find a match with the short name, includes it in the list of
matches and then expands it to the long name.
See https://en.wikipedia.org/wiki/Long_filename

--
ARTHUR: Now stand aside worthy adversary.
BLACK KNIGHT: (Glancing at his shoulder) 'Tis but a scratch.
ARTHUR: A scratch? Your arm's off.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20230429132628.E64621C09E0%40moolenaar.net.

No comments:

Post a Comment