Eli Zaretskii wrote:
> > 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.
> 
> Well, at the very least how about documenting this subtlety?

Done as follows:


2019-09-28  Bruno Haible  <br...@clisp.org>

        access: Document limitations on Windows.
        Suggested by Zaretskii <e...@gnu.org>.
        * doc/posix-functions/access.texi: Mention two limitations on Windows.

diff --git a/doc/posix-functions/access.texi b/doc/posix-functions/access.texi
index 49064d2..8bfa2c1 100644
--- a/doc/posix-functions/access.texi
+++ b/doc/posix-functions/access.texi
@@ -31,4 +31,17 @@ this function, especially in a set-uid or set-gid program.
 This function does not have an option for not following symbolic links
 (like @code{stat} versus @code{lstat}).  If you need this option, use
 the Gnulib module @code{faccessat} with the @code{AT_EACCESS} flag.
+@item
+On native Windows, files whose basename does not contain a @samp{.}
+cannot be executed through @code{execlp} or @code{execvp}.  Nevertheless,
+this function may return true for such files.
+@item
+On Windows, different facilities for executing a program have different
+ways of finding an executable file, by trying various suffixes.  For
+example, @code{execlp} and @code{execvp} search for files with the
+suffixes @code{.com}, @code{.exe}, @code{.bat}, @code{.cmd}, when the
+file with the given file name does not exist.  Whereas @code{cmd.exe}
+searches according to the @code{PATHEXT} environment variable.  This
+function does not perform any search; it merely looks at the file with
+the given file name.
 @end itemize


Reply via email to