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

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

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


From: Leo Alekseyev
Subject: Quoting shell arguments in start-process; escaping " in strings
Date: Mon, 17 Jan 2011 19:12:06 -0500

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]