emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH]: grep-default-command


From: Juri Linkov
Subject: Re: [PATCH]: grep-default-command
Date: Tue, 24 Aug 2010 19:09:36 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu)

> +        ;; Here's explanation: a shell arg can be a series of these 3 things:
> +        ;;
> +        ;; 1) Double quoted thing, in which double quote can occur, but must 
> be led by the escape ?\\
> +        ;; 2) Single quoted thing, in which anything except the single quote 
> can occur
> +        ;; 3) Non-quoted thing, in which some special chars can not occur, 
> unless they are led by escape.
> +        ;;
> +        ;; Trick is to get the correct number of escapes!
> +
> +     (sh-arg-re 
> "\\(\\(?:\"\\(?:\\\\\"\\|[^\"]\\)+\"\\|'[^']+'\\|\\(?:\\\\.\\|[^\"' 
> \\|><\t\n]\\)\\)+\\)")

Thanks for your patch.  It's better to send patches to
address@hidden to make sure they don't fall into oblivion.

Shell argument parsing in grep-default-command is too unreliable
and may have more problems other that you mentioned.

So I suggest to use more reliable function `comint-arguments', e.g.

(let ((comint-delimiter-argument-list shell-delimiter-argument-list))
  (mapcar (lambda (arg) (comint-arguments (car grep-history) arg arg)) '(0 1 2 
3 4)))

At least, it passes all your tests (where "#" and "literal t"
below mean text properties put over the substring):

grep -inH -e "x\"y" *.el
("grep"
 "-inH"
 "-e"
 "\"x\\\"y\""
 "*.el")

grep -inH -e x\"y *.el
("grep"
 "-inH"
 "-e"
 #("x\\\"y" 1 3 (literal t))
 "*.el")

grep -inH -e aa\ bb *.el
("grep"
 "-inH"
 "-e"
 #("aa\\ bb" 2 4 (literal t))
 "*.el")

grep -inH -e aa|bb *.el
("grep"
 "-inH"
 "-e"
 "aa"
 "|"
 "bb"
 "*.el")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]