diff options
author | Karl Heuer <kwzh@gnu.org> | 1999-07-20 04:16:51 +0000 |
---|---|---|
committer | Karl Heuer <kwzh@gnu.org> | 1999-07-20 04:16:51 +0000 |
commit | 5f49d5e88dc25b579f651c9ed48c213cc0dd21f5 (patch) | |
tree | c428bae45ec47cf1e6e78ec84673c1371724de3d /lisp/shell.el | |
parent | 9b80213097501f0fc0dd1fa65af403e0492f7660 (diff) | |
download | emacs-5f49d5e88dc25b579f651c9ed48c213cc0dd21f5.tar.gz |
(shell-unquote-argument): New function.
(shell-directory-tracker): Use shell-unquote-argument.
Diffstat (limited to 'lisp/shell.el')
-rw-r--r-- | lisp/shell.el | 21 |
1 files changed, 21 insertions, 0 deletions
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))) |