all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#57247: [PATCH] em-unix.el: only pass -H option to grep
@ 2022-08-16 17:17 Brendan O'Dea
  2022-08-17 11:20 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Brendan O'Dea @ 2022-08-16 17:17 UTC (permalink / raw)
  To: 57247

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

Tags: patch

A recent change to eshell-grep added the -H option to cmd in order to
ensure that the filename is always included in the output.

This is fine for grep/egrep/fgrep, but breaks other uses if they don't
support that flag: e.g. agrep/glimpse appear to use -H for a
completely different purpose, one which requires an argument.

In my case, I'm using it to define some eshell commands for some
internal search tools which don't support the flag.

Attached is a patch which moves the addition of the -H option only to
the functions which call grep.

--bod

[-- Attachment #2: em-unix.patch --]
[-- Type: text/x-patch, Size: 1158 bytes --]

diff --git a/lisp/eshell/em-unix.el b/lisp/eshell/em-unix.el
index 68276b22d95..40b83010f94 100644
--- a/lisp/eshell/em-unix.el
+++ b/lisp/eshell/em-unix.el
@@ -755,26 +755,21 @@ eshell-grep
 				      (eshell-stringify-list
 				       (flatten-tree args)))
 			      " "))
-	     (cmd (format "%s -nH %s"
-			  (pcase command
-			    ("egrep" "grep -E")
-			    ("fgrep" "grep -F")
-			    (x x))
-			  args))
+	     (cmd (format "%s -n %s" command args))
 	     compilation-scroll-output)
 	(grep cmd)))))
 
 (defun eshell/grep (&rest args)
   "Use Emacs grep facility instead of calling external grep."
-  (eshell-grep "grep" args t))
+  (eshell-grep "grep" (append '("-H") args) t))
 
 (defun eshell/egrep (&rest args)
   "Use Emacs grep facility instead of calling external grep -E."
-  (eshell-grep "egrep" args t))
+  (eshell-grep "grep" (append '("-EH") args) t))
 
 (defun eshell/fgrep (&rest args)
   "Use Emacs grep facility instead of calling external grep -F."
-  (eshell-grep "fgrep" args t))
+  (eshell-grep "grep" (append '("-FH") args) t))
 
 (defun eshell/agrep (&rest args)
   "Use Emacs grep facility instead of calling external agrep."

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

* bug#57247: [PATCH] em-unix.el: only pass -H option to grep
  2022-08-16 17:17 bug#57247: [PATCH] em-unix.el: only pass -H option to grep Brendan O'Dea
@ 2022-08-17 11:20 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2022-08-17 11:20 UTC (permalink / raw)
  To: Brendan O'Dea; +Cc: 57247

"Brendan O'Dea" <bod@debian.org> writes:

> Attached is a patch which moves the addition of the -H option only to
> the functions which call grep.

Thanks; pushed to Emacs 29.






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

end of thread, other threads:[~2022-08-17 11:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-16 17:17 bug#57247: [PATCH] em-unix.el: only pass -H option to grep Brendan O'Dea
2022-08-17 11:20 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.