Eli Zaretskii wrote: > > > > +@item > > > > +This function does not support the @code{X_OK} mode on some platforms: > > > > +MSVC 14. > > > > > > This says MSVC, but the code will do the same on MinGW, right? > > > > Yes, I enabled this code also on mingw. With the mingw version I tested, > > it is a no-op, because that mingw version links against an older MSVCRT > > runtime. If/when mingw starts to link against newer Microsoft ucrt runtimes, > > it will be affected by the same problem. > > I'm saying that the documentation should mention MinGW as well, > because currently it gives an impression that only MSVC builds are > affected in any way.
So far, only MSVC builds are affected. The gnulib documentation lists situations/platforms that we _know_ are buggy. There is always the implicit statement "If a situation/platform is not mentioned explicitly it may still be buggy". For example, often FreeBSD 6.0 is mentioned to have a certain bug, although the bug may also exist in FreeBSD 11 and 12 - simply because I don't have the time to verify each bug on each new version of FreeBSD. > > Should it look whether the file extension is one of the known ones? > > Definitely not. When you rename a file prog.exe to prog.foo and invoke > > it through execlp/execvp, it works. And '.foo' is surely not one of the > > "known" file extensions. > > You describe a very unusual situation, because prog.foo will not be > found by the Windows shell and by many other programs that use the > shell via the likes of 'system' and 'popen'. I think it's better to > be 90% correct than do nothing about this issue because we cannot > easily be 100% correct. Callers don't usually expect an X_OK test to > degenerate into F_OK, IMO. > > IOW, I think this implementation doesn't live up to Gnulib's promise > to be a portability layer, because it loses too much of the baby with > the bath water. There are different ways to test for "executable" on Windows: - execlp/execvp, - CreateProcess, - system / popen, like you say, - cmd.exe, - surely more (PowerShell...) Let's assume that they work differently (cmd.exe definitely works differently than execlp/execvp; I tested that). The module does not attempt to handle all of these, just the first one, because - the function access() is located at the C library level, - it is compatible with what the old MSVCRT (without the argument check for the mode in _access()) does. If you consider the gnulib access() function unfit for some purpose, you must also consider the old MSVCRT _acccess() function unfit for the same purpose. Bruno