From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.pretest.bugs,gmane.emacs.devel Subject: Re: Emacsclient/server filename quoting error Date: Fri, 15 Dec 2006 13:06:16 +0200 Message-ID: References: <001701c71c53$1be9a9f0$041df159@Monolith> Reply-To: Eli Zaretskii NNTP-Posting-Host: dough.gmane.org X-Trace: sea.gmane.org 1166180800 26834 80.91.229.10 (15 Dec 2006 11:06:40 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 15 Dec 2006 11:06:40 +0000 (UTC) Cc: F.J.Wright@qmul.ac.uk, emacs-devel@gnu.org, emacs-pretest-bug@gnu.org Original-X-From: emacs-pretest-bug-bounces+gebp-emacs-pretest-bug=gmane.org@gnu.org Fri Dec 15 12:06:38 2006 Return-path: Envelope-to: gebp-emacs-pretest-bug@gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by dough.gmane.org with esmtp (Exim 4.50) id 1GvAta-0000Jr-N7 for gebp-emacs-pretest-bug@gmane.org; Fri, 15 Dec 2006 12:06:30 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GvAta-0001Ng-72 for gebp-emacs-pretest-bug@gmane.org; Fri, 15 Dec 2006 06:06:30 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GvAtO-0001LR-AN for emacs-pretest-bug@gnu.org; Fri, 15 Dec 2006 06:06:18 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GvAtM-0001HX-8S for emacs-pretest-bug@gnu.org; Fri, 15 Dec 2006 06:06:17 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GvAtM-0001HB-2l; Fri, 15 Dec 2006 06:06:16 -0500 Original-Received: from [192.114.186.66] (helo=romy.inter.net.il) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GvAtL-0008C2-JW; Fri, 15 Dec 2006 06:06:15 -0500 Original-Received: from HOME-C4E4A596F7 (IGLD-84-228-202-146.inter.net.il [84.228.202.146]) by romy.inter.net.il (MOS 3.7.3-GA) with ESMTP id GNW26485 (AUTH halo1); Fri, 15 Dec 2006 13:06:12 +0200 (IST) Original-To: "Juanma Barranquero" In-reply-to: (lekktu@gmail.com) X-BeenThere: emacs-pretest-bug@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for CVS Emacs." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-pretest-bug-bounces+gebp-emacs-pretest-bug=gmane.org@gnu.org Errors-To: emacs-pretest-bug-bounces+gebp-emacs-pretest-bug=gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.pretest.bugs:15792 gmane.emacs.devel:63762 Archived-At: > Date: Fri, 15 Dec 2006 11:31:18 +0100 > From: "Juanma Barranquero" > Cc: emacs-pretest-bug@gnu.org, Emacs Devel > > > I execute all the following commands from a cmd command > > prompt (outside of Emacs). > > > > emacsclient -n -a runemacs "TO DO.txt" > > > > works correctly if Emacs IS already running, but if it is not > > already running then Emacs does not see the filename correctly; > > the quotes do not appear to be passed on to runemacs. > > The following patch addresses the issue by allocating quoted copies of > any argument containing spaces before calling execvp. > > Any objections to install this fix? As it stands, it affects also > non-Windows builds. Is requoting args the right behavior in these > environments? Quoting arguments passed to execvp is _definitely_ the wrong thing for Posix platforms. The fact that we need to do that for Windows is due to the broken implementation of exec* routines in the Microsoft libraries: they concatenate the arguments together without quoting special characters, and pass the result to CreateProcess, with predictably bad results. By contrast, Posix execvp passes the arguments directly into the argv[] array of the child process. So please make this change conditioned on WINDOWSNT. Actually, a cleaner way of fixing this would be to have a WINDOWSNT-only wrapper for execvp, called, say w32_execvp, that does TRT with quoting the arguments. Then you could say #ifdef WINDOWSNT #define execvp w32_execvp #endif in emacsclient.c, and leave the mainline code intact.