From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Leo Alekseyev Newsgroups: gmane.emacs.help Subject: Re: Quoting shell arguments in start-process; escaping " in strings Date: Tue, 18 Jan 2011 00:16:54 -0500 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1295327843 5444 80.91.229.12 (18 Jan 2011 05:17:23 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 18 Jan 2011 05:17:23 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jan 18 06:17:19 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Pf3wU-0004S8-IM for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Jan 2011 06:17:18 +0100 Original-Received: from localhost ([127.0.0.1]:40298 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pf3wT-0007kc-I2 for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Jan 2011 00:17:17 -0500 Original-Received: from [140.186.70.92] (port=33043 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pf3w8-0007kU-6S for help-gnu-emacs@gnu.org; Tue, 18 Jan 2011 00:16:57 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pf3w7-0005tJ-2L for help-gnu-emacs@gnu.org; Tue, 18 Jan 2011 00:16:56 -0500 Original-Received: from mail-fx0-f41.google.com ([209.85.161.41]:65061) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pf3w6-0005t5-S6 for help-gnu-emacs@gnu.org; Tue, 18 Jan 2011 00:16:55 -0500 Original-Received: by fxm12 with SMTP id 12so6745858fxm.0 for ; Mon, 17 Jan 2011 21:16:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=qS1WkSOwTZ/p1vCGukk0aY2GFSkT2m7orPY+GvyZYsI=; b=GUhzfBc6fwBEJNmINpTepWVm2xcXf2S5snfOh8O2dAZbAWe758TlK6X1P2Tq+oufy3 9L05/mphc3ajjqingS9ptDGqGGhvFqn5f4264+EqnBm69yWxblBl3tTm2Ht3aBc/K/SE wH/1YB4NBynzLV6+f69jJCIykKV4cgPZzzEbw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=h5By0LVE6oe90aHlKXF3nNw7w+SQ/qHkPvHy0cbJZVPcr4MkBegZ4ZOQuBCkglgEqN MrsG9PLaYqs3ESLPrGL6tP2XyLmfR+MU+EVrxK6YcdRAZMSJ6wyGAW9bIdNKNZgr5oTD rkj8OIefLzCH7cgrYUtb7xWYGOXGo27pVkc0k= Original-Received: by 10.223.72.15 with SMTP id k15mr4198217faj.54.1295327814062; Mon, 17 Jan 2011 21:16:54 -0800 (PST) Original-Received: by 10.223.101.131 with HTTP; Mon, 17 Jan 2011 21:16:54 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:78524 Archived-At: Answering my own question here... Since I'm doing bash -c at the command line, the correct format is, of course, (start-process "test" nil "bash" "-c" "bash -c \"c:/PROGRA~1/WOLFRA~1/MATHEM~1/8.0/MATHEM~1.EXE \\\"c:\\home\\leo\\tmp\\test spc.nb\\\"\"") Or, (start-process-shell-command "test" nil cmd) where cmd is the last argument above. This ugliness is what one has to resort to when (w32-shell-execute...) fails on a particular group of files. On Mon, Jan 17, 2011 at 7:12 PM, Leo Alekseyev wrote: > I am trying to fix poor handling of links in org-mode under Windows. > > I need to issue the following command using start-process (note the > space in file name): > $ bash -c "c:/PROGRA~1/WOLFRA~1/MATHEM~1/8.0/MATHEM~1.EXE > \"c:\\home\\leo\\tmp\\test spc.nb\"" > ;; This runs fine in M-x shell > > I can't figure out how to quote the last argument properly when using > (start-process). =A0Can someone please enlighten me as to the proper > procedure?.. =A0Here's what doesn't work: > > - Trying to issue that command as written at the command prompt makes > the quotes disappear: > (start-process "test" nil "bash" "-c" > "c:/PROGRA~1/WOLFRA~1/MATHEM~1/8.0/MATHEM~1.EXE > \"c:\\home\\leo\\tmp\\test spc.nb\"") > > The effective command line becomes > c:/PROGRA~1/WOLFRA~1/MATHEM~1/8.0/MATHEM~1.EXE c:\home\leo\tmp\test > spc.nb (no quotes). > > - Trying single quotes to protect the space, i.e. =A0(start-process > "test" nil "bash" "-c" "c:/PROGRA~1/WOLFRA~1/MATHEM~1/8.0/MATHEM~1.EXE > 'c:\\home\\leo\\tmp\\test spc.nb'"), the effective command line > becomes c:/PROGRA~1/WOLFRA~1/MATHEM~1/8.0/MATHEM~1.EXE > "c:\\home\\leo\\tmp\\test spc.nb" (quotes, but erroneous > double-backshlashes -- why?.. =A0Shouldn't emacs convert \\ to \?..). > > - Trying to escape both the backslashes and the quotation marks (the > result is verbatim \, missing "): > (start-process "test" nil "bash" "-c" > "c:/PROGRA~1/WOLFRA~1/MATHEM~1/8.0/MATHEM~1.EXE > \\\"c:\\home\\leo\\tmp\\test spc.nb\\\"") > The effective command line becomes > c:/PROGRA~1/WOLFRA~1/MATHEM~1/8.0/MATHEM~1.EXE \c:\home\leo\tmp\test > spc.nb\ > > Is there a way to prevent (start-process) from stripping quotes under > all circumstance, which is what it seems to be doing?.. > Note also that shell-quote-arguments *does not* do the right thing in > this example because I have to use a combination of Unix and DOS-style > paths. > > --Leo >