Hi,

previously egrep/fgrep shows as egrep/fgrep in ps output, now it
shows as 'grep -E'/'grep -F'. Personally I don't see much problem in
it, but I received some bug reports regarding it downstream. My question
is, what about using symlinks for egrep/fgrep and something similar
to the attached patch? Or are scripts used to support platforms
without symlinks? Or is there different reason for script usage?

thanks & regards

Jaroslav
diff --git a/src/grep.c b/src/grep.c
--- a/src/grep.c
+++ b/src/grep.c
@@ -26,6 +26,7 @@
 #include <fcntl.h>
 #include <inttypes.h>
 #include <stdio.h>
+#include <string.h>
 #include "system.h"
 
 #include "argmatch.h"
@@ -1938,6 +1939,7 @@ fgrep_to_grep_pattern (size_t len, char const *keys,
 int
 main (int argc, char **argv)
 {
+  char *ptr_c;
   char *keys;
   size_t keycc, oldcc, keyalloc;
   bool with_filenames;
@@ -1984,6 +1986,19 @@ main (int argc, char **argv)
   compile = matchers[0].compile;
   execute = matchers[0].execute;
 
+  /* Check if executed through symlinks egrep/fgrep */
+  if (argv[0] != NULL)
+    {
+      ptr_c = strchrnul(argv[0], ' ');
+      if (ptr_c - argv[0] >= 5)
+        {
+          if (strncmp(ptr_c - 5, "egrep", 5) == 0)
+            setmatcher ("egrep");
+          else if (strncmp(ptr_c - 5, "fgrep", 5) == 0)
+            setmatcher ("fgrep");
+        }
+    }
+
   while (prev_optind = optind,
          (opt = get_nondigit_option (argc, argv, &default_context)) != -1)
     switch (opt)

Reply via email to