]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/progmodes/compile.el (compilation-start): Try to handle common
authorStefan Monnier <monnier@iro.umontreal.ca>
Tue, 23 Oct 2012 19:07:44 +0000 (15:07 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Tue, 23 Oct 2012 19:07:44 +0000 (15:07 -0400)
quoting of `cd' argument.

Fixes: debbugs:12640
lisp/ChangeLog
lisp/progmodes/compile.el

index 05b7cfc176e86c35eb1809909823563a061c7b05..df7420c30a333383f6bf6a42a32619c18eb19dc2 100644 (file)
@@ -1,5 +1,8 @@
 2012-10-23  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+       * progmodes/compile.el (compilation-start): Try to handle common
+       quoting of `cd' argument (bug#12640).
+
        * vc/diff-mode.el (diff-hunk): `save-excursion' while refining
        (bug#12671).
 
index 10fd7a75eaaa88b8eceaf0294f92e6bc90e3ddac..06525b354b18e7e0323c713aa4850154196310e1 100644 (file)
@@ -1568,12 +1568,20 @@ Returns the compilation buffer created."
        ;; Then evaluate a cd command if any, but don't perform it yet, else
        ;; start-command would do it again through the shell: (cd "..") AND
        ;; sh -c "cd ..; make"
-       (cd (if (string-match "\\`\\s *cd\\(?:\\s +\\(\\S +?\\)\\)?\\s *[;&\n]"
-                             command)
-               (if (match-end 1)
-                   (substitute-env-vars (match-string 1 command))
-                 "~")
-             default-directory))
+       (cd (cond
+             ((not (string-match "\\`\\s *cd\\(?:\\s +\\(\\S +?\\|'[^']*'\\|\"\\(?:[^\"`$\\]\\|\\\\.\\)*\"\\)\\)?\\s *[;&\n]"
+                                 command))
+              default-directory)
+             ((not (match-end 1)) "~")
+             ((eq (aref command (match-beginning 1)) ?\')
+              (substring command (1+ (match-beginning 1))
+                         (1- (match-end 1))))
+             ((eq (aref command (match-beginning 1)) ?\")
+              (replace-regexp-in-string
+               "\\\\\\(.\\)" "\\1"
+               (substring command (1+ (match-beginning 1))
+                          (1- (match-end 1)))))
+             (t (substitute-env-vars (match-string 1 command)))))
        (erase-buffer)
        ;; Select the desired mode.
        (if (not (eq mode t))