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: Quoting shell arguments in start-process; escaping " in strings Date: Mon, 17 Jan 2011 19:12:06 -0500 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1295309780 5120 80.91.229.12 (18 Jan 2011 00:16:20 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 18 Jan 2011 00:16:20 +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 01:16:16 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 1PezCe-0001AW-SV for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Jan 2011 01:16:16 +0100 Original-Received: from localhost ([127.0.0.1]:40882 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PezCV-0008St-Dv for geh-help-gnu-emacs@m.gmane.org; Mon, 17 Jan 2011 19:13:31 -0500 Original-Received: from [140.186.70.92] (port=42507 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PezCB-0008RR-MP for help-gnu-emacs@gnu.org; Mon, 17 Jan 2011 19:13:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PezBz-0005P5-JB for help-gnu-emacs@gnu.org; Mon, 17 Jan 2011 19:13:00 -0500 Original-Received: from mail-fx0-f41.google.com ([209.85.161.41]:40534) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PezBz-0005KG-Dr for help-gnu-emacs@gnu.org; Mon, 17 Jan 2011 19:12:59 -0500 Original-Received: by fxm12 with SMTP id 12so6574303fxm.0 for ; Mon, 17 Jan 2011 16:12:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=pwE56YyaU12jHxaDxkHb/1nyn6UmtWwBYYdZnL6SAl4=; b=ipmC57UrheEUs1xOcg7eXnjmhSY/2I7z0UH1wxTEE6/TJZ6w/WaEEczF/plpfiQcoK WlWk/UiFUliEnrzoYgqZ/Af5KM6fDXcindSiGeYODuHg9+TQF3xo9RK2DPorsZZ8zxDk 1oKDHe1srR+rZFE+Cy2tntYMJ9YXWW20xUZLE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=wTctIyYOV04nnNxhZX2aZ/ggyD0NUTTFkc1niHW2iVZhRrZ8PUPFT1uVN59AjwePwt QL/5SHvRirlbgXTXqCVs/UwH3fRapPXwAH1ipEo3oE8qSjRmDVY5deWeDLz/LiUfNIL3 PWaYxI7yLHfjucH+6YYWdPTX58AgZRwQz4fOI= Original-Received: by 10.223.101.140 with SMTP id c12mr5507169fao.16.1295309526964; Mon, 17 Jan 2011 16:12:06 -0800 (PST) Original-Received: by 10.223.101.131 with HTTP; Mon, 17 Jan 2011 16:12:06 -0800 (PST) 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:78520 Archived-At: 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). Can someone please enlighten me as to the proper procedure?.. Here'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. (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?.. Shouldn'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