* lisp/shell.el (shell-parse-pcomplete-arguments): Unquote args.
authorStefan Monnier <monnier@iro.umontreal.ca>
Sun, 28 Aug 2011 05:15:17 +0000 (01:15 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Sun, 28 Aug 2011 05:15:17 +0000 (01:15 -0400)
Fixes: debbugs:9160

lisp/ChangeLog
lisp/shell.el

index 8a57fe7..552c3f5 100644 (file)
@@ -1,3 +1,7 @@
+2011-08-28  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * shell.el (shell-parse-pcomplete-arguments): Unquote args (bug#9160).
+
 2011-08-27  Alan Mackenzie  <acm@muc.de>
 
        * progmodes/cc-menus.el (cc-imenu-c++-generic-expression): Make it
index 01d1a68..909ebb4 100644 (file)
@@ -393,10 +393,28 @@ to `dirtrack-mode'."
       (while (< (point) end)
        (skip-chars-forward " \t\n")
        (push (point) begins)
-        (looking-at "\\(?:[^\s\t\n\\]\\|'[^']*'\\|\"\\(?:[^\"\\]\\|\\\\.\\)*\"\\|\\\\.\\)*\\(?:\\\\\\|'[^']*\\|\"\\(?:[^\"\\]\\|\\\\.\\)*\\)?")
-        (goto-char (match-end 0))
-       (push (buffer-substring-no-properties (car begins) (point))
-              args))
+        (let ((arg ()))
+          (while (looking-at
+                  (eval-when-compile
+                    (concat
+                     "\\(?:[^\s\t\n\\\"']+"
+                     "\\|'\\([^']*\\)'?"
+                     "\\|\"\\(\\(?:[^\"\\]\\|\\\\.\\)*\\)\"?"
+                     "\\|\\\\\\(\\(?:.\\|\n\\)?\\)\\)")))
+            (goto-char (match-end 0))
+            (cond
+             ((match-beginning 3)       ;Backslash escape.
+              (push (if (= (match-beginning 3) (match-end 3))
+                        "\\" (match-string 3))
+                    arg))
+             ((match-beginning 2)       ;Double quote.
+              (push (replace-regexp-in-string
+                     "\\\\\\(.\\)" "\\1" (match-string 2))
+                    arg))
+             ((match-beginning 1)       ;Single quote.
+              (push (match-string 1) arg))
+             (t (push (match-string 0) arg))))
+          (push (mapconcat #'identity (nreverse arg) "") args)))
       (cons (nreverse args) (nreverse begins)))))
 
 (defun shell-completion-vars ()