From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Juanma Barranquero" Newsgroups: gmane.emacs.pretest.bugs,gmane.emacs.devel Subject: Re: Emacsclient/server filename quoting error Date: Fri, 15 Dec 2006 11:31:18 +0100 Message-ID: References: <001701c71c53$1be9a9f0$041df159@Monolith> NNTP-Posting-Host: dough.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1166178919 20535 80.91.229.10 (15 Dec 2006 10:35:19 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 15 Dec 2006 10:35:19 +0000 (UTC) Cc: emacs-pretest-bug@gnu.org, Emacs Devel Original-X-From: emacs-pretest-bug-bounces+gebp-emacs-pretest-bug=gmane.org@gnu.org Fri Dec 15 11:35:16 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 1GvAPM-0004pn-5t for gebp-emacs-pretest-bug@gmane.org; Fri, 15 Dec 2006 11:35:16 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GvAPL-0002Kx-81 for gebp-emacs-pretest-bug@gmane.org; Fri, 15 Dec 2006 05:35:15 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GvALf-00084G-T3 for emacs-pretest-bug@gnu.org; Fri, 15 Dec 2006 05:31:28 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GvALc-00081R-II for emacs-pretest-bug@gnu.org; Fri, 15 Dec 2006 05:31:25 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GvALb-00080s-8P for emacs-pretest-bug@gnu.org; Fri, 15 Dec 2006 05:31:23 -0500 Original-Received: from [64.233.184.236] (helo=wr-out-0506.google.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GvALb-0008Bw-1t for emacs-pretest-bug@gnu.org; Fri, 15 Dec 2006 05:31:23 -0500 Original-Received: by wr-out-0506.google.com with SMTP id i12so353718wra for ; Fri, 15 Dec 2006 02:31:22 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Ytcrh6WhbQdE78DQyQN4QN+mTqzrZL4wdlZKP00JqDRiBC6O+hJjJW0l1zOQsFFioSj5E8LkRJ/Nd7eq+lRuHrzhw8oSAib7wzK6q2ZT1FSqEfuqt6Qprdj65FQLQtWBQI3iRBgqYgq+nq9rjEcrK01eXzm9paclg6pS41f/dw4= Original-Received: by 10.49.68.6 with SMTP id v6mr2277224nfk.1166178678688; Fri, 15 Dec 2006 02:31:18 -0800 (PST) Original-Received: by 10.82.147.2 with HTTP; Fri, 15 Dec 2006 02:31:18 -0800 (PST) Original-To: "Francis Wright" In-Reply-To: <001701c71c53$1be9a9f0$041df159@Monolith> Content-Disposition: inline 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:15790 gmane.emacs.devel:63758 Archived-At: On 12/10/06, Francis Wright wrote: > 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? /L/e/k/t/u Index: lib-src/emacsclient.c =================================================================== RCS file: /cvsroot/emacs/emacs/lib-src/emacsclient.c,v retrieving revision 1.98 diff -u -2 -r1.98 emacsclient.c --- lib-src/emacsclient.c 30 Nov 2006 22:49:38 -0000 1.98 +++ lib-src/emacsclient.c 15 Dec 2006 10:19:44 -0000 @@ -310,8 +310,20 @@ if (alternate_editor) { - int i = optind - 1; + int j, i = optind - 1; + #ifdef WINDOWSNT - argv[i] = (char *)alternate_editor; + argv[i] = (char *) alternate_editor; #endif + + /* Arguments with spaces have been dequoted, so we + have to requote them before calling execvp. */ + for (j = i; argv[j]; j++) + if (strchr (argv[j], ' ')) + { + char *quoted = alloca (strlen (argv[j]) + 3); + sprintf (quoted, "\"%s\"", argv[j]); + argv[j] = quoted; + } + execvp (alternate_editor, argv + i); message (TRUE, "%s: error executing alternate editor \"%s\"\n",