changeset 24967:03990f1d9e2d

(shell-unquote-argument): New function. (shell-directory-tracker): Use shell-unquote-argument.
author Karl Heuer <kwzh@gnu.org>
date Tue, 20 Jul 1999 04:16:51 +0000
parents bfa093996074
children ced85898ea55
files lisp/shell.el
diffstat 1 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/shell.el	Tue Jul 20 01:46:01 1999 +0000
+++ b/lisp/shell.el	Tue Jul 20 04:16:51 1999 +0000
@@ -542,6 +542,8 @@
 	      (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 @@
 				 (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)))