Prefer grep -E/-F to egrep/fgrep

POSIX marked egrep and fgrep as legacy apps in SUSv2 (1997) and
withdrew them in SUSv3 (2001), and these days grep -E and grep -F
are probably more portable.
* lib-src/etags.c (main):
* lisp/eshell/em-unix.el (eshell-grep, eshell/egrep)
(eshell/fgrep):
* lisp/cedet/semantic/symref.el (semantic-symref-find-text):
* lisp/eshell/esh-var.el (eshell-apply-indices):
* lisp/progmodes/ada-xref.el (ada-xref-search-with-egrep)
(ada-find-in-src-path):
* lisp/textmodes/ispell.el (ispell-grep-command):
(ispell-lookup-words):
Use or document grep -E and grep -F instead of egrep and fgrep.
* lisp/textmodes/ispell.el (ispell-grep-options):
Use -Ei on all platforms, not just MS-Windows.
This commit is contained in:
Paul Eggert 2016-05-07 18:40:10 -07:00
parent 4c175a6af5
commit e8bda380bb
6 changed files with 19 additions and 18 deletions

View file

@ -1343,7 +1343,7 @@ main (int argc, char **argv)
{
char *cmd =
xmalloc (strlen (tagfile) + whatlen_max +
sizeof "mv..OTAGS;fgrep -v '\t\t' OTAGS >;rm OTAGS");
sizeof "mv..OTAGS;grep -Fv '\t\t' OTAGS >;rm OTAGS");
for (i = 0; i < current_arg; ++i)
{
switch (argbuffer[i].arg_type)
@ -1356,7 +1356,7 @@ main (int argc, char **argv)
}
char *z = stpcpy (cmd, "mv ");
z = stpcpy (z, tagfile);
z = stpcpy (z, " OTAGS;fgrep -v '\t");
z = stpcpy (z, " OTAGS;grep -Fv '\t");
z = stpcpy (z, argbuffer[i].what);
z = stpcpy (z, "\t' OTAGS >");
z = stpcpy (z, tagfile);

View file

@ -271,7 +271,7 @@ Optional SCOPE specifies which file set to search. Defaults to `project'.
Refers to `semantic-symref-tool', to determine the reference tool to use
for the current buffer.
Returns an object of class `semantic-symref-result'."
(interactive "sEgrep style Regexp: ")
(interactive "sGrep -E style Regexp: ")
(let* ((inst (semantic-symref-instantiate
:searchfor text
:searchtype 'regexp

View file

@ -748,7 +748,12 @@ external command."
(cmd (progn
(set-text-properties 0 (length args)
'(invisible t) args)
(format "%s -n %s" command args)))
(format "%s -n %s"
(pcase command
("egrep" "grep -E")
("fgrep" "grep -F")
(x x))
args)))
compilation-scroll-output)
(grep cmd)))))
@ -757,11 +762,11 @@ external command."
(eshell-grep "grep" args t))
(defun eshell/egrep (&rest args)
"Use Emacs grep facility instead of calling external egrep."
"Use Emacs grep facility instead of calling external grep -E."
(eshell-grep "egrep" args t))
(defun eshell/fgrep (&rest args)
"Use Emacs grep facility instead of calling external fgrep."
"Use Emacs grep facility instead of calling external grep -F."
(eshell-grep "fgrep" args t))
(defun eshell/agrep (&rest args)

View file

@ -530,7 +530,7 @@ Integers imply a direct index, and names, an associate lookup using
For example, to retrieve the second element of a user's record in
'/etc/passwd', the variable reference would look like:
${egrep johnw /etc/passwd}[: 2]"
${grep johnw /etc/passwd}[: 2]"
(while indices
(let ((refs (car indices)))
(when (stringp value)

View file

@ -174,7 +174,7 @@ If GVD is not the debugger used, nothing happens."
:type 'boolean :group 'ada)
(defcustom ada-xref-search-with-egrep t
"If non-nil, use egrep to find the possible declarations for an entity.
"If non-nil, use grep -E to find the possible declarations for an entity.
This alternate method is used when the exact location was not found in the
information provided by GNAT. However, it might be expensive if you have a lot
of sources, since it will search in all the files in your project."
@ -2013,7 +2013,7 @@ This function should be used when the standard algorithm that parses the
exist.
This function attempts to find the possible declarations for the identifier
anywhere in the object path.
This command requires the external `egrep' program to be available.
This command requires the external `grep' program to be available.
This works well when one is using an external library and wants to find
the declaration and documentation of the subprograms one is using."

View file

@ -396,19 +396,15 @@ Always stores Fcc copy of message when nil."
(defcustom ispell-grep-command
;; MS-Windows/MS-DOS have `egrep' as a Unix shell script, so they
;; cannot invoke it. Use "grep -E" instead (see ispell-grep-options
;; below).
(if (memq system-type '(windows-nt ms-dos)) "grep" "egrep")
"grep"
"Name of the grep command for search processes."
:type 'string
:group 'ispell)
(defcustom ispell-grep-options
(if (memq system-type '(windows-nt ms-dos)) "-Ei" "-i")
"-Ei"
"String of options to use when running the program in `ispell-grep-command'.
Should probably be \"-i\" or \"-e\".
Some machines (like the NeXT) don't support \"-i\"."
Should probably be \"-Ei\"."
:type 'string
:group 'ispell)
@ -2678,8 +2674,8 @@ SPC: Accept word this time.
(defun ispell-lookup-words (word &optional lookup-dict)
"Look up WORD in optional word-list dictionary LOOKUP-DICT.
A `*' serves as a wild card. If no wild cards, `look' is used if it exists.
Otherwise the variable `ispell-grep-command' contains the command used to
search for the words (usually egrep).
Otherwise the variable `ispell-grep-command' contains the command
\(usually \"grep\") used to search for the words.
Optional second argument contains the dictionary to use; the default is
`ispell-alternate-dictionary', overridden by `ispell-complete-word-dict'