comparison lisp/shell.el @ 24967:03990f1d9e2d

(shell-unquote-argument): New function. (shell-directory-tracker): Use shell-unquote-argument.
author Karl Heuer <kwzh@gnu.org>
date Tue, 20 Jul 1999 04:16:51 +0000
parents b84d9bdd06b1
children cbe304a26771
comparison
equal deleted inserted replaced
24966:bfa093996074 24967:03990f1d9e2d
540 end cmd arg1) 540 end cmd arg1)
541 (while (string-match shell-command-regexp str start) 541 (while (string-match shell-command-regexp str start)
542 (setq end (match-end 0) 542 (setq end (match-end 0)
543 cmd (comint-arguments (substring str start end) 0 0) 543 cmd (comint-arguments (substring str start end) 0 0)
544 arg1 (comint-arguments (substring str start end) 1 1)) 544 arg1 (comint-arguments (substring str start end) 1 1))
545 (if arg1
546 (setq arg1 (shell-unquote-argument arg1)))
545 (cond ((string-match (concat "\\`\\(" shell-popd-regexp 547 (cond ((string-match (concat "\\`\\(" shell-popd-regexp
546 "\\)\\($\\|[ \t]\\)") 548 "\\)\\($\\|[ \t]\\)")
547 cmd) 549 cmd)
548 (shell-process-popd (comint-substitute-in-file-name arg1))) 550 (shell-process-popd (comint-substitute-in-file-name arg1)))
549 ((string-match (concat "\\`\\(" shell-pushd-regexp 551 ((string-match (concat "\\`\\(" shell-pushd-regexp
560 cmd)) 562 cmd))
561 (shell-process-cd (comint-substitute-in-file-name cmd)))) 563 (shell-process-cd (comint-substitute-in-file-name cmd))))
562 (setq start (progn (string-match "[; \t]*" str end) ; skip again 564 (setq start (progn (string-match "[; \t]*" str end) ; skip again
563 (match-end 0))))) 565 (match-end 0)))))
564 (error "Couldn't cd")))) 566 (error "Couldn't cd"))))
567
568 (defun shell-unquote-argument (string)
569 "Remove all kinds of shell quoting from STRING."
570 (save-match-data
571 (let ((idx 0) next inside)
572 (while (and (< idx (length string))
573 (setq next (string-match "[\\'`\"]" string next)))
574 (cond ((= (aref string next) ?\\)
575 (setq string (replace-match "" nil nil string))
576 (setq next (1+ next)))
577 ((and inside (= (aref string next) inside))
578 (setq string (replace-match "" nil nil string))
579 (setq inside nil))
580 (inside
581 (setq next (1+ next)))
582 (t
583 (setq inside (aref string next))
584 (setq string (replace-match "" nil nil string)))))
585 string)))
565 586
566 ;;; popd [+n] 587 ;;; popd [+n]
567 (defun shell-process-popd (arg) 588 (defun shell-process-popd (arg)
568 (let ((num (or (shell-extract-num arg) 0))) 589 (let ((num (or (shell-extract-num arg) 0)))
569 (cond ((and num (= num 0) shell-dirstack) 590 (cond ((and num (= num 0) shell-dirstack)