Commit 5f49d5e8 authored by Karl Heuer's avatar Karl Heuer
Browse files

(shell-unquote-argument): New function.

(shell-directory-tracker): Use shell-unquote-argument.
parent 9b802130
......@@ -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]\\)")
......@@ -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."
(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))
(setq next (1+ next)))
(setq inside (aref string next))
(setq string (replace-match "" nil nil string)))))
;;; popd [+n]
(defun shell-process-popd (arg)
(let ((num (or (shell-extract-num arg) 0)))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment