unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#21548: 25.0.50; [PATCH] Prevent empty -path arguments for not-ignored directories in rgrep's find commands
@ 2015-09-24 11:28 Phil Sainty
  2015-09-30  7:43 ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: Phil Sainty @ 2015-09-24 11:28 UTC (permalink / raw)
  To: 21548

[-- Attachment #1: Type: text/plain, Size: 565 bytes --]

In GNU Emacs 25.0.50.1 (x86_64-unknown-linux-gnu, X toolkit, Xaw3d 
scroll bars)
  of 2015-09-05
Repository revision: 2330ca33a97867f2ea1123bcf7bfe5cfcc030b36


rgrep's `grep-find-ignored-directories' conditional-ignore behaviour
(for list elements which are cons cells) produces 'find' constraints
like: "find . -type d \( -path  -o -path \*/SCCS [...]" (i.e. a -path
argument with no value) when the associated function returns nil.

The nil elements need to be deleted from the list before the command
line arguments for the ignored directories are generated.



[-- Attachment #2: 0001-Prevent-empty-path-arguments-in-rgrep-find-commands.patch --]
[-- Type: text/x-patch, Size: 2345 bytes --]

From fa2ebb275e0ec1f88e154d55022548084d442736 Mon Sep 17 00:00:00 2001
From: Phil Sainty <psainty@orcon.net.nz>
Date: Thu, 24 Sep 2015 23:16:14 +1200
Subject: [PATCH] Prevent empty -path arguments in rgrep find commands

rgrep's `grep-find-ignored-directories' conditional-ignore behaviour
(for list elements which are cons cells) produces 'find' constraints
like: "find . -type d \( -path  -o -path \*/SCCS [...]" (i.e. a -path
argument with no value) when the associated function returns nil.

The nil elements need to be deleted from the list before the command
line arguments are generated.
---
 lisp/progmodes/grep.el | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 3240ee8..452a42f 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -1039,16 +1039,18 @@ to specify a command to run."
                  ;; we should use shell-quote-argument here
                  " -path "
                  (mapconcat
-                  #'(lambda (ignore)
-                      (cond ((stringp ignore)
-                             (shell-quote-argument
-                              (concat "*/" ignore)))
-                            ((consp ignore)
-                             (and (funcall (car ignore) dir)
-                                  (shell-quote-argument
-                                   (concat "*/"
-                                           (cdr ignore)))))))
-                  grep-find-ignored-directories
+                  'identity
+                  (delq nil (mapcar
+                             #'(lambda (ignore)
+                                 (cond ((stringp ignore)
+                                        (shell-quote-argument
+                                         (concat "*/" ignore)))
+                                       ((consp ignore)
+                                        (and (funcall (car ignore) dir)
+                                             (shell-quote-argument
+                                              (concat "*/"
+                                                      (cdr ignore)))))))
+                             grep-find-ignored-directories))
                   " -o -path ")
                  " "
                  (shell-quote-argument ")")
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#21548: 25.0.50; [PATCH] Prevent empty -path arguments for not-ignored directories in rgrep's find commands
  2015-09-24 11:28 bug#21548: 25.0.50; [PATCH] Prevent empty -path arguments for not-ignored directories in rgrep's find commands Phil Sainty
@ 2015-09-30  7:43 ` Eli Zaretskii
  0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2015-09-30  7:43 UTC (permalink / raw)
  To: Phil Sainty; +Cc: 21548-done

> Date: Thu, 24 Sep 2015 23:28:39 +1200
> From: Phil Sainty <psainty@orcon.net.nz>
> 
> rgrep's `grep-find-ignored-directories' conditional-ignore behaviour
> (for list elements which are cons cells) produces 'find' constraints
> like: "find . -type d \( -path  -o -path \*/SCCS [...]" (i.e. a -path
> argument with no value) when the associated function returns nil.
> 
> The nil elements need to be deleted from the list before the command
> line arguments for the ignored directories are generated.

Thanks, I pushed this.

Please in the future accompany your patches with a ChangeLog-format
commit message; see CONTRIBUTE for details.

We seem to lack tests for this stuff (and Grep in general).  Would you
like to write some tests for that?  TIA.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-09-30  7:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-24 11:28 bug#21548: 25.0.50; [PATCH] Prevent empty -path arguments for not-ignored directories in rgrep's find commands Phil Sainty
2015-09-30  7:43 ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).