Mercurial > emacs
comparison lisp/shell.el @ 35643:cafc43e2ccfd
(shell-unquote-argument): If the shell is one of the
mentioned in shell-dumb-shell-regexp, don't treat a backslash as a
quote character.
(shell-dumb-shell-regexp): Document that the shells which match
this regexp are supposed to not treat a backslash as a quote
character.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sat, 27 Jan 2001 12:41:59 +0000 |
parents | 8c460ceb4916 |
children | aa45cec8f927 |
comparison
equal
deleted
inserted
replaced
35642:15b0b31760c7 | 35643:cafc43e2ccfd |
---|---|
120 "Faces in shell buffers" | 120 "Faces in shell buffers" |
121 :group 'shell) | 121 :group 'shell) |
122 | 122 |
123 ;;;###autoload | 123 ;;;###autoload |
124 (defcustom shell-dumb-shell-regexp "cmd\\(proxy\\)?\\.exe" | 124 (defcustom shell-dumb-shell-regexp "cmd\\(proxy\\)?\\.exe" |
125 "Regexp to match shells that don't save their command history. | 125 "Regexp to match shells that don't save their command history, and |
126 For shells that match this regexp, Emacs will write out the | 126 don't handle the backslash as a quote character. For shells that |
127 command history when the shell finishes." | 127 match this regexp, Emacs will write out the command history when the |
128 shell finishes, and won't remove backslashes when it unquotes shell | |
129 arguments." | |
128 :type 'regexp | 130 :type 'regexp |
129 :group 'shell) | 131 :group 'shell) |
130 | 132 |
131 (defcustom shell-prompt-pattern "^[^#$%>\n]*[#$%>] *" | 133 (defcustom shell-prompt-pattern "^[^#$%>\n]*[#$%>] *" |
132 "Regexp to match prompts in the inferior shell. | 134 "Regexp to match prompts in the inferior shell. |
595 (error "Couldn't cd")))) | 597 (error "Couldn't cd")))) |
596 | 598 |
597 (defun shell-unquote-argument (string) | 599 (defun shell-unquote-argument (string) |
598 "Remove all kinds of shell quoting from STRING." | 600 "Remove all kinds of shell quoting from STRING." |
599 (save-match-data | 601 (save-match-data |
600 (let ((idx 0) next inside) | 602 (let ((idx 0) next inside |
603 (quote-chars | |
604 (if (string-match shell-dumb-shell-regexp | |
605 (file-name-nondirectory | |
606 (car (process-command (get-buffer-process (current-buffer)))))) | |
607 "['`\"]" | |
608 "[\\'`\"]"))) | |
601 (while (and (< idx (length string)) | 609 (while (and (< idx (length string)) |
602 (setq next (string-match "[\\'`\"]" string next))) | 610 (setq next (string-match quote-chars string next))) |
603 (cond ((= (aref string next) ?\\) | 611 (cond ((= (aref string next) ?\\) |
604 (setq string (replace-match "" nil nil string)) | 612 (setq string (replace-match "" nil nil string)) |
605 (setq next (1+ next))) | 613 (setq next (1+ next))) |
606 ((and inside (= (aref string next) inside)) | 614 ((and inside (= (aref string next) inside)) |
607 (setq string (replace-match "" nil nil string)) | 615 (setq string (replace-match "" nil nil string)) |