I do not know of any shell that has a feature that would allow one to do command preprocessing, but I have managed to persuade shell-mode in emacs to do what you want.
Emacs shell-mode can be customized by setting some variables defined in the comint package. Put the following code in a file with ending ".el" (emacs lisp), and load it with the command "M-x load-file". After that, opening a shell buffer with "M-x shell" will give you a "shell" that does what you want. Quoting is achieved by enclosing the text to quote with "my-quote()".
Emacs lisp code:
(defun my-quote-function (s) "quote special chars in string" (shell-quote-argument s)) (defun my-input-sender (proc command) "specialized comint-input-sender function with extra quoting" (let ((quoting-regex "my-quote(\\(.*\\))")) (string-match quoting-regex command) (let ((string-to-quote (match-string 1 command))) (if (null string-to-quote) (comint-simple-send proc command) (let ((quoted-string (my-quote-function string-to-quote))) (string-match quoting-regex command) (comint-simple-send proc (replace-match quoted-string t t command))))))) (setq comint-input-sender 'my-input-sender)
Works like this (excerpt from shell mode buffer):
--> echo $foo --> echo my-quote($foo) $foo --> echo "This is not quoted but" my-quote("this") is This is not quoted but "this" is -->
Christian Lemburg
Brainbench MVP for Perl
http://www.brainbench.com
In reply to Re: Command line preprocessing
by clemburg
in thread Command line preprocessing
by suaveant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |