]> code.delx.au - gnu-emacs/blobdiff - lisp/shell.el
(log-view-goto-rev): New function for the new VC.
[gnu-emacs] / lisp / shell.el
index aee3866c6e6b1c6c5dd37f4844f7b5517d8738c3..13d1d9adb6f4b437f3c1b001a5e90a51e746db40 100644 (file)
@@ -3,7 +3,7 @@
 ;; Copyright (C) 1988, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
 
 ;; Author: Olin Shivers <shivers@cs.cmu.edu> then
-;;     Simon Marshall <simon@gnu.ai.mit.edu>
+;;     Simon Marshall <simon@gnu.org>
 ;; Maintainer: FSF
 ;; Keywords: processes
 
@@ -29,7 +29,7 @@
 ;; Please send me bug reports, bug fixes, and extensions, so that I can
 ;; merge them into the master source.
 ;;     - Olin Shivers (shivers@cs.cmu.edu)
-;;     - Simon Marshall (simon@gnu.ai.mit.edu)
+;;     - Simon Marshall (simon@gnu.org)
 
 ;; This file defines a a shell-in-a-buffer package (shell mode) built
 ;; on top of comint mode.  This is actually cmushell with things
@@ -542,6 +542,8 @@ Environment variables are expanded, see function `substitute-in-file-name'."
              (setq end (match-end 0)
                    cmd (comint-arguments (substring str start end) 0 0)
                    arg1 (comint-arguments (substring str start end) 1 1))
+             (if arg1
+                 (setq arg1 (shell-unquote-argument arg1)))
              (cond ((string-match (concat "\\`\\(" shell-popd-regexp
                                           "\\)\\($\\|[ \t]\\)")
                                   cmd)
@@ -563,6 +565,25 @@ Environment variables are expanded, see function `substitute-in-file-name'."
                                 (match-end 0)))))
        (error "Couldn't cd"))))
 
+(defun shell-unquote-argument (string)
+  "Remove all kinds of shell quoting from STRING."
+  (save-match-data
+    (let ((idx 0) next inside)
+      (while (and (< idx (length string))
+                 (setq next (string-match "[\\'`\"]" string next)))
+       (cond ((= (aref string next) ?\\)
+              (setq string (replace-match "" nil nil string))
+              (setq next (1+ next)))
+             ((and inside (= (aref string next) inside))
+              (setq string (replace-match "" nil nil string))
+              (setq inside nil))
+             (inside
+              (setq next (1+ next)))
+             (t
+              (setq inside (aref string next))
+              (setq string (replace-match "" nil nil string)))))
+      string)))
+
 ;;; popd [+n]
 (defun shell-process-popd (arg)
   (let ((num (or (shell-extract-num arg) 0)))