Author: gabor
Date: Thu Dec  1 13:53:08 2011
New Revision: 228179
URL: http://svn.freebsd.org/changeset/base/228179

Log:
  MFC 228093
  
    - Fix behavior of --null to match GNU grep
  
  MFC 228097
  
    - Call warnx() instead of errx() if a directory is not readable when using
      a recursive search.  This is the expected behavior instead of aborting.
  
  Approved by:  re (kib)

Modified:
  stable/9/usr.bin/grep/util.c
Directory Properties:
  stable/9/usr.bin/grep/   (props changed)

Modified: stable/9/usr.bin/grep/util.c
==============================================================================
--- stable/9/usr.bin/grep/util.c        Thu Dec  1 11:36:41 2011        
(r228178)
+++ stable/9/usr.bin/grep/util.c        Thu Dec  1 13:53:08 2011        
(r228179)
@@ -130,7 +130,9 @@ grep_tree(char **argv)
                case FTS_DNR:
                        /* FALLTHROUGH */
                case FTS_ERR:
-                       errx(2, "%s: %s", p->fts_path, strerror(p->fts_errno));
+                       notfound = true;
+                       if(!sflag)
+                               warnx("%s: %s", p->fts_path, 
strerror(p->fts_errno));
                        break;
                case FTS_D:
                        /* FALLTHROUGH */
@@ -246,9 +248,9 @@ procfile(const char *fn)
                printf("%u\n", c);
        }
        if (lflag && !qflag && c != 0)
-               printf("%s\n", fn);
+               printf("%s%c", fn, nullflag ? 0 : '\n');
        if (Lflag && !qflag && c == 0)
-               printf("%s\n", fn);
+               printf("%s%c", fn, nullflag ? 0 : '\n');
        if (c && !cflag && !lflag && !Lflag &&
            binbehave == BINFILE_BIN && f->binary && !qflag)
                printf(getstr(8), fn);
@@ -440,13 +442,13 @@ printline(struct str *line, int sep, reg
        int i, n = 0;
 
        if (!hflag) {
-               if (nullflag == 0)
+               if (!nullflag) {
                        fputs(line->file, stdout);
-               else {
+                       ++n;
+               } else {
                        printf("%s", line->file);
                        putchar(0);
                }
-               ++n;
        }
        if (nflag) {
                if (n > 0)
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to