emacs-devel
[Top][All Lists]
Advanced

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

Re: Using `call-process-shell-command' in `process-lines'


From: Eli Zaretskii
Subject: Re: Using `call-process-shell-command' in `process-lines'
Date: Mon, 26 Nov 2007 22:59:36 +0200

> From: Stefan Monnier <address@hidden>
> Cc: "Juanma Barranquero" <address@hidden>,  address@hidden
> Date: Mon, 26 Nov 2007 15:35:51 -0500
> 
> > If this minor variant works:
> 
> >    (apply #'call-process "c:/bin/gnuwin32/bin/find.exe" nil
> >      (get-buffer-create "output") nil '("c:/emacs/trunk/lisp/" "-name"
> >      (shell-quote-argument "*.el")))
> 
> > it might give you a clue to the solution.  The call to
> > shell-quote-argument should be limited to Windows only, since the
> > Windows implementation of the library function called by call-process
> > constructs a single command line out of all arguments, which of course
> > means you need an extra pair of quotes.
> 
> But this library function already does the necessary quoting.

??? What library function do you have in mind, and where do you see
its quoting?

> The problem seems to be that under Windows, the globbing is not done by
> the shell but by the application

True.  But the result is the same in most cases.  Note that ``by the
application'' means here the wildcards are expanded by the startup
code that runs before the `main' function.  And `find' clearly wants
to expand the wildcards itself, in the code invoked by its own `main'.

> so while under Unix no globbing is
> performed (because no shell is involved) under Windows `find'
> performs globbing.

Yes, and therein lies the misfeature I described earlier: since
spawnve _knows_ it will be invoking the child program in a way that
might expand wildcards before the wildcards get to the application
code, it _must_ quote wildcards (and other special characters,
including whitespace), so as to emulate the semantics of the Posix
execve.

> I'd be surprised if it's the first time this happens.  What solutions
> have we used in the other cases where this problem showed up?

I'm guessing that other invocations of `find', for example, leave it
to the user to type arguments, so Windows users quote the wildcards,
as they are accustomed to do from the shell prompt.

Anyway, the right solution, IMO, is to wrap spawnve with quoting code.




reply via email to

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