bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: new module 'system-quote'


From: Eli Zaretskii
Subject: Re: new module 'system-quote'
Date: Thu, 10 May 2012 19:20:38 +0300

> From: Bruno Haible <address@hidden>
> Cc: address@hidden
> Date: Thu, 10 May 2012 11:29:17 +0200
> 
> > > If I recall it correctly, the
> > >   check_one (interpreter, prog, "*");
> > > case failed: Apparently, when you pass a single unquoted '*' argument
> > > to CreateProcess, it can fail with GetLastError() = ERROR_PATH_NOT_FOUND.
> > 
> > That is expected and reasonable: the first token in the argument is
> > the executable to invoke, so it cannot possibly include wildcards.
> 
> There's a misunderstanding. I know that the CreateProcess() does less
> processing on the first token than on the remaining ones (the arguments),
> therefore the code is made for the arguments, and the unit test also
> tests the arguments.

Sorry for my misunderstanding.  However, ...

> If you want to see what happens, just remove the '*' from
> SHELL_SPECIAL_CHARS and re-run the unit test.

I see this:

  for input = |*|: CreateProcess() command failed with status 3: 
.\test-system-quote-child.exe *

But IIUC that just means we hit this condition in the child:

  if (argc > 2)
    /* Expected one data argument, received more than one.  */
    return 3;

IOW, it got several arguments, where only one was expected.  This is
perfectly normal, since "*" (unquoted) will expand into the list of
all the files in the current directory.  If I hack
test-system-quote-child.c as follows:

--- test-system-quote-child.c~0 2012-05-09 19:50:17.000000000 +0300
+++ test-system-quote-child.c   2012-05-10 19:15:50.732750000 +0300
@@ -32,8 +32,13 @@ main (int argc, char *argv[])
     /* Expected one data argument, received none.  */
     return 2;
   if (argc > 2)
-    /* Expected one data argument, received more than one.  */
-    return 3;
+    {
+      /* Expected one data argument, received more than one.  */
+      int i;
+      for (i = 1; i < argc; i++)
+       fprintf (stderr, "%d: `%s'\n", i, argv[i]);
+      return 3;
+    }
   arg = argv[1];
 
   /* Read the contents of EXPECTED_DATA_FILE.  */

I see 305 argv[] elements printed to stderr.

So this is not a failure of CreateProcess, this is expected and
correct behavior.  Or am I again missing something?

If I'm not missing anything, I submit that '*' should be removed from
the list of special characters.  Leaving it there means that it will
be impossible to invoke programs with arguments that include
wildcards.

Thanks.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]