From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Using `call-process-shell-command' in `process-lines' Date: Mon, 26 Nov 2007 22:59:36 +0200 Message-ID: References: Reply-To: Eli Zaretskii NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1196110805 31695 80.91.229.12 (26 Nov 2007 21:00:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 26 Nov 2007 21:00:05 +0000 (UTC) Cc: lekktu@gmail.com, emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 26 22:00:11 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Iwl3o-0003uI-7P for ged-emacs-devel@m.gmane.org; Mon, 26 Nov 2007 22:00:08 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Iwl3Z-0004iW-4Q for ged-emacs-devel@m.gmane.org; Mon, 26 Nov 2007 15:59:53 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Iwl3V-0004fs-4K for emacs-devel@gnu.org; Mon, 26 Nov 2007 15:59:49 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Iwl3U-0004eh-Fd for emacs-devel@gnu.org; Mon, 26 Nov 2007 15:59:48 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Iwl3U-0004eQ-5I for emacs-devel@gnu.org; Mon, 26 Nov 2007 15:59:48 -0500 Original-Received: from nitzan.inter.net.il ([213.8.233.22]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Iwl3T-0008Ls-KP for emacs-devel@gnu.org; Mon, 26 Nov 2007 15:59:47 -0500 Original-Received: from HOME-C4E4A596F7 ([81.5.42.135]) by nitzan.inter.net.il (MOS 3.7.3a-GA) with ESMTP id IKP37026 (AUTH halo1); Mon, 26 Nov 2007 22:57:00 +0200 (IST) In-reply-to: (message from Stefan Monnier on Mon, 26 Nov 2007 15:35:51 -0500) X-detected-kernel: by monty-python.gnu.org: FreeBSD 4.7-5.2 (or MacOS X 10.2-10.4) (2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:84178 Archived-At: > From: Stefan Monnier > Cc: "Juanma Barranquero" , 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.