From: Karl Heuer Date: Tue, 20 Jul 1999 04:16:51 +0000 (+0000) Subject: (shell-unquote-argument): New function. X-Git-Tag: emacs-pretest-21.0.90~7474 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5f49d5e88dc25b579f651c9ed48c213cc0dd21f5;p=emacs.git (shell-unquote-argument): New function. (shell-directory-tracker): Use shell-unquote-argument. --- diff --git a/lisp/shell.el b/lisp/shell.el index aee3866c6e6..a2887f82792 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -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)))