;;;###autoload
(defvar grep-find-use-xargs nil
- "Non-nil means that `grep-find' uses the `xargs' utility by default.
-If `exec', use `find -exec'.
+ "How to invoke find and grep.
+If `exec', use `find -exec {} ;'.
+If `exec-plus' use `find -exec {} +'.
If `gnu', use `find -print0' and `xargs -0'.
-Any other non-nil value means to use `find -print' and `xargs'.
+Any other value means to use `find -print' and `xargs'.
This variable's value takes effect when `grep-compute-defaults' is called.")
(unless grep-find-use-xargs
(setq grep-find-use-xargs
(cond
+ ((grep-probe find-program
+ `(nil nil nil ,null-device "-exec" "echo"
+ "{}" "+"))
+ 'exec-plus)
((and
(grep-probe find-program `(nil nil nil ,null-device "-print0"))
(grep-probe xargs-program `(nil nil nil "-0" "-e" "echo")))
;; forward slashes as directory separators.
(format "%s . -type f -print0 | \"%s\" -0 -e %s"
find-program xargs-program grep-command))
- ((eq grep-find-use-xargs 'exec)
+ ((memq grep-find-use-xargs '(exec exec-plus))
(let ((cmd0 (format "%s . -type f -exec %s"
- find-program grep-command)))
+ find-program grep-command))
+ (null (if grep-use-null-device
+ (format "%s " null-device)
+ "")))
(cons
- (format "%s {} %s %s"
- cmd0 null-device
- (shell-quote-argument ";"))
+ (if (eq grep-find-use-xargs 'exec-plus)
+ (format "%s %s{} +" cmd0 null)
+ (format "%s {} %s%s" cmd0 null
+ (shell-quote-argument ";")))
(1+ (length cmd0)))))
(t
(format "%s . -type f -print | \"%s\" %s"
(unless grep-find-template
(setq grep-find-template
(let ((gcmd (format "%s <C> %s <R>"
- grep-program grep-options)))
+ grep-program grep-options))
+ (null (if grep-use-null-device
+ (format "%s " null-device)
+ "")))
(cond ((eq grep-find-use-xargs 'gnu)
(format "%s . <X> -type f <F> -print0 | \"%s\" -0 -e %s"
find-program xargs-program gcmd))
((eq grep-find-use-xargs 'exec)
- (format "%s . <X> -type f <F> -exec %s {} %s %s"
- find-program gcmd null-device
+ (format "%s . <X> -type f <F> -exec %s {} %s%s"
+ find-program gcmd null
(shell-quote-argument ";")))
+ ((eq grep-find-use-xargs 'exec-plus)
+ (format "%s . <X> -type f <F> -exec %s %s{} +"
+ find-program gcmd null))
(t
(format "%s . <X> -type f <F> -print | \"%s\" %s"
find-program xargs-program gcmd))))))))