unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: lekktu@gmail.com, emacs-devel@gnu.org
Subject: Re: Using `call-process-shell-command' in `process-lines'
Date: Mon, 26 Nov 2007 22:59:36 +0200	[thread overview]
Message-ID: <uejec3epz.fsf@gnu.org> (raw)
In-Reply-To: <jwvtzn89284.fsf-monnier+emacs@gnu.org> (message from Stefan Monnier on Mon, 26 Nov 2007 15:35:51 -0500)

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: "Juanma Barranquero" <lekktu@gmail.com>,  emacs-devel@gnu.org
> 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	other threads:[~2007-11-26 20:59 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-26 14:11 Using `call-process-shell-command' in `process-lines' Juanma Barranquero
2007-11-26 15:35 ` Stefan Monnier
2007-11-26 16:01   ` Juanma Barranquero
2007-11-26 16:43     ` Stefan Monnier
2007-11-26 17:01       ` Juanma Barranquero
2007-11-26 17:28         ` Lennart Borgman (gmail)
2007-11-26 17:59           ` Juanma Barranquero
2007-11-26 19:58             ` Lennart Borgman (gmail)
2007-11-26 20:50               ` Eli Zaretskii
2007-11-26 21:25                 ` Lennart Borgman (gmail)
2007-11-26 22:04                   ` Eli Zaretskii
2007-11-26 22:16                     ` Lennart Borgman (gmail)
2007-11-26 22:22                       ` Eli Zaretskii
2007-11-26 22:39                         ` Lennart Borgman (gmail)
2007-11-27  4:08                           ` Eli Zaretskii
2007-11-27 22:34                             ` Lennart Borgman (gmail)
2007-11-26 22:17                     ` Eli Zaretskii
2007-11-26 22:35                       ` Lennart Borgman (gmail)
2007-11-26 20:38           ` Eli Zaretskii
2007-11-26 20:23         ` Eli Zaretskii
2007-11-26 20:30           ` Eli Zaretskii
2007-11-26 20:31           ` Lennart Borgman (gmail)
2007-11-26 20:51             ` Eli Zaretskii
2007-11-26 21:08               ` Lennart Borgman (gmail)
2007-11-26 21:18                 ` Eli Zaretskii
2007-11-26 21:23                   ` Lennart Borgman (gmail)
2007-11-26 21:49                     ` Eli Zaretskii
2007-11-26 22:17                       ` Jason Rumney
2007-11-26 22:29                         ` Eli Zaretskii
2007-11-26 22:30                         ` Jason Rumney
2007-11-27  0:24                           ` Juanma Barranquero
2007-11-26 22:33                         ` Eli Zaretskii
2007-11-26 23:01                           ` Jason Rumney
2007-11-27  4:13                             ` Eli Zaretskii
2007-11-26 20:35           ` Stefan Monnier
2007-11-26 20:59             ` Eli Zaretskii [this message]
2007-11-26 21:18               ` Lennart Borgman (gmail)
2007-11-26 16:04   ` Juanma Barranquero

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=uejec3epz.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=lekktu@gmail.com \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).