help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Quoting shell arguments in start-process; escaping " in strings


From: Leo Alekseyev
Subject: Re: Quoting shell arguments in start-process; escaping " in strings
Date: Tue, 18 Jan 2011 00:16:54 -0500

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 <dnquark@gmail.com> 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).  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
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]