Reputation: 41209
(shell-command "\"C:\\Documents and Settings\\ggustafson\\Desktop\\stuff\\ctags58\\ctags.exe\" -eR -f \"C:\\Documents and Settings\\ggustafson\\Desktop\\BlueTooth_7020\\TAGS\" \"C:\\Documents and Settings\\ggustafson\\Desktop\\BlueTooth_7020\"")
(message "\"C:\\Documents and Settings\\ggustafson\\Desktop\\stuff\\ctags58\\ctags.exe\" -eR -f \"C:\\Documents and Settings\\ggustafson\\Desktop\\BlueTooth_7020\\TAGS\" \"C:\\Documents and Settings\\ggustafson\\Desktop\\BlueTooth_7020\"")
Executing the top form gives me the error 'C:\Documents' is not recognized as an internal or external command, operable program or batch file.
. Executing the output the second form puts into the *Messages*
buffer works as intended (creates a tags file).
Why am I not getting the same results with both techniques? Does shell-command
do something that changes the string before sending it to the shell? How can I use elisp to execute a string exactly as if I had pasted it into a command prompt?
shell-quote-argument
does not work either as it produces a string that cannot be executed with either method:
(message (shell-quote-argument "\"C:\\Documents and Settings\\ggustafson\\Desktop\\stuff\\ctags58\\ctags.exe\" -eR -f \"C:\\Documents and Settings\\ggustafson\\Desktop\\BlueTooth_7020\\TAGS\" \"C:\\Documents and Settings\\ggustafson\\Desktop\\BlueTooth_7020\""))
"^\"\\^\"C:\\Documents and Settings\\ggustafson\\Desktop\\stuff\\ctags58\\ctags.exe\\^\" -eR -f \\^\"C:\\Documents and Settings\\ggustafson\\Desktop\\BlueTooth_7020\\TAGS\\^\" \\^\"C:\\Documents and Settings\\ggustafson\\Desktop\\BlueTooth_7020\\^\"^\""
Upvotes: 0
Views: 592
Reputation: 28531
I'd strongly recommend you use call-program
instead of shell-command
here, since you don't use any of the features of the shell, and it just gets in the way, forcing you to do quoting gymnastics to explain to the shell what you mean.
Upvotes: 0
Reputation: 9380
I would suggest you to doublecheck both if executions are using same path, and therefore same ctags.exe
. I think that might be the problem. You may want to use the full path to ctags.exe
to make sure of that.
My ctags (Linux) gives me the same error if I use the -Re
option on a normal shell; that is what makes me think that way.
Upvotes: 1
Reputation: 73256
shell-quote-argument
is for quoting a single argument to a shell command (hence the name), not a shell command in its entirety.
Given that the error you were seeing suggested a lack of quoting somewhere, it seemed like a good idea to use the built-in command to deal with quoting rather than writing it manually and assuming you had the correct syntax.
Another alternative is using M-! to execute the command (or a similar one) interactively, figure out what gets accepted, and then afterwards use C-xM-: to obtain the elisp form.
Upvotes: 2