# HG changeset patch # User Karl Heuer # Date 932444211 0 # Node ID 03990f1d9e2db2b0563d9b428f1892d0559c5378 # Parent bfa09399607458e0ac7bc823fba7b1d5b2ef655d (shell-unquote-argument): New function. (shell-directory-tracker): Use shell-unquote-argument. diff -r bfa093996074 -r 03990f1d9e2d lisp/shell.el --- 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)))