Subject: bug#11348: 24.0.95; TAB-completion in shell-command produces d:\/foo on MS-Windows

From: Chong Yidong <[email-masked]>
Date: Mon, 07 May 2012 16:01:15 +0800

Eli Zaretskii <[email-masked]> writes:

>> I installed the patch below, which seems to fix this specific problem
>> (according to my testing under Wine ;-)
>
> I'm not sure why it worked for you, because it still doesn't for me.

I also still see the bug, running under Wine.

> IOW, the problem is that shell-parse-pcomplete-arguments removes the
> backslash in "d:\gnu", because the last alternative in the above
> regexp treats backslashes as escape characters, which on MS-DOS and
> MS-Windows is true (for shell commands) only when the backslash
> precedes a quote character (").

How about something like the following?  (Works for me on Wine with your
test case, but I don't know if it breaks quoting.)

=== modified file 'lisp/shell.el'
*** lisp/shell.el	2012-05-05 04:18:49 +0000
--- lisp/shell.el	2012-05-07 07:59:33 +0000
***************
*** 397,402 ****
--- 397,408 ----
                       ((null pcomplete-arg-quote-list)
                        (goto-char (match-beginning 3)) "\\")
                       ((= (match-beginning 3) (match-end 3)) "\\")
+ 		     ;; On Windows, the backslash is an escape
+ 		     ;; character only if it precedes a quote char.
+ 		     ((and (memq system-type
+ 				 '(ms-dos windows-nt darwin cygwin))
+ 			   (not (equal (match-string 3) "\"")))
+ 		      (concat "/" (match-string 3)))
                       (t (match-string 3)))
                      arg))
               ((match-beginning 2)       ;Double quote.