grep-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

grep branch, master, updated. v3.1-8-g92526f7


From: Paul Eggert
Subject: grep branch, master, updated. v3.1-8-g92526f7
Date: Thu, 17 Aug 2017 17:18:05 -0400 (EDT)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  92526f7246464825c5547ceb08e01433e035c867 (commit)
       via  bfcad04c5ef73c7d78eeff32127ee8e0462307db (commit)
      from  d7a308a7d54db953bf86d8e44728a011416eeac2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=92526f7246464825c5547ceb08e01433e035c867


commit 92526f7246464825c5547ceb08e01433e035c867
Author: Paul Eggert <address@hidden>
Date:   Thu Aug 17 14:15:35 2017 -0700

    grep: -L exits with status 0 if a file is selected
    
    Problem reported by Anthony Sottile (Bug#28105).
    * NEWS, doc/grep.texi (Exit Status), src/grep.c (usage): Document this.
    * src/grep.c (grepdesc): Implement it.
    * tests/skip-read: Test it.

diff --git a/NEWS b/NEWS
index 81f51b5..9ed78fb 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,11 @@ GNU grep NEWS                                    -*- outline 
-*-
 
 * Noteworthy changes in release ?.? (????-??-??) [?]
 
+** Changes in behavior
+
+  The --files-without-match (-L) option now causes grep to succeed
+  when a file is listed, instead of when a line is selected.  This
+  resembles what git-grep does.
 
 * Noteworthy changes in release 3.1 (2017-07-02) [stable]
 
diff --git a/doc/grep.texi b/doc/grep.texi
index 24800c9..865acf1 100644
--- a/doc/grep.texi
+++ b/doc/grep.texi
@@ -1067,6 +1067,9 @@ and only when @env{POSIXLY_CORRECT} is not set.
 
 Normally the exit status is 0 if a line is selected, 1 if no lines
 were selected, and 2 if an error occurred.  However, if the
address@hidden or @option{--files-without-match} is used, the exit status
+is 0 if a file is listed, 1 if no files were listed, and 2 if an error
+occurred.  Also, if the
 @option{-q} or @option{--quiet} or @option{--silent} option is used
 and a line is selected, the exit status is 0 even if an error
 occurred.  Other @command{grep} implementations may exit with status
diff --git a/src/grep.c b/src/grep.c
index a37e87b..5847c7a 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -1863,11 +1863,11 @@ grepdesc (int desc, bool command_line)
         fflush_errno ();
     }
 
-  status = !count;
+  status = !count != (list_files == LISTFILES_NONMATCHING);
 
   if (list_files == LISTFILES_NONE)
     finalize_input (desc, &st, ineof);
-  else if (list_files == (status ? LISTFILES_NONMATCHING : LISTFILES_MATCHING))
+  else if (status == 0)
     {
       print_filename ();
       putchar_errno ('\n' & filename_mask);
@@ -1994,7 +1994,7 @@ Context control:\n\
       printf (_("\
 When FILE is '-', read standard input.  With no FILE, read '.' if\n\
 recursive, '-' otherwise.  With fewer than two FILEs, assume -h.\n\
-Exit status is 0 if any line is selected, 1 otherwise;\n\
+Exit status is 0 if any line (or file if -L) is selected, 1 otherwise;\n\
 if any error occurs and -q is not given, the exit status is 2.\n"));
       emit_bug_reporting_address ();
     }
diff --git a/tests/skip-read b/tests/skip-read
index 1eef87e..3c32c48 100755
--- a/tests/skip-read
+++ b/tests/skip-read
@@ -15,7 +15,7 @@ for opts in '-m0 y' '-f /dev/null' '-v ""'; do
       eval returns_ 1 grep -l $opts $matcher /dev/null > out || fail=1
       compare /dev/null out || fail=1
     done
-    eval returns_ 1 grep -L $opts $matcher /dev/null > out || fail=1
+    eval grep -L $opts $matcher /dev/null > out || fail=1
     compare exp out || fail=1
   done
 done

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=bfcad04c5ef73c7d78eeff32127ee8e0462307db


commit 92526f7246464825c5547ceb08e01433e035c867
Author: Paul Eggert <address@hidden>
Date:   Thu Aug 17 14:15:35 2017 -0700

    grep: -L exits with status 0 if a file is selected
    
    Problem reported by Anthony Sottile (Bug#28105).
    * NEWS, doc/grep.texi (Exit Status), src/grep.c (usage): Document this.
    * src/grep.c (grepdesc): Implement it.
    * tests/skip-read: Test it.

diff --git a/NEWS b/NEWS
index 81f51b5..9ed78fb 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,11 @@ GNU grep NEWS                                    -*- outline 
-*-
 
 * Noteworthy changes in release ?.? (????-??-??) [?]
 
+** Changes in behavior
+
+  The --files-without-match (-L) option now causes grep to succeed
+  when a file is listed, instead of when a line is selected.  This
+  resembles what git-grep does.
 
 * Noteworthy changes in release 3.1 (2017-07-02) [stable]
 
diff --git a/doc/grep.texi b/doc/grep.texi
index 24800c9..865acf1 100644
--- a/doc/grep.texi
+++ b/doc/grep.texi
@@ -1067,6 +1067,9 @@ and only when @env{POSIXLY_CORRECT} is not set.
 
 Normally the exit status is 0 if a line is selected, 1 if no lines
 were selected, and 2 if an error occurred.  However, if the
address@hidden or @option{--files-without-match} is used, the exit status
+is 0 if a file is listed, 1 if no files were listed, and 2 if an error
+occurred.  Also, if the
 @option{-q} or @option{--quiet} or @option{--silent} option is used
 and a line is selected, the exit status is 0 even if an error
 occurred.  Other @command{grep} implementations may exit with status
diff --git a/src/grep.c b/src/grep.c
index a37e87b..5847c7a 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -1863,11 +1863,11 @@ grepdesc (int desc, bool command_line)
         fflush_errno ();
     }
 
-  status = !count;
+  status = !count != (list_files == LISTFILES_NONMATCHING);
 
   if (list_files == LISTFILES_NONE)
     finalize_input (desc, &st, ineof);
-  else if (list_files == (status ? LISTFILES_NONMATCHING : LISTFILES_MATCHING))
+  else if (status == 0)
     {
       print_filename ();
       putchar_errno ('\n' & filename_mask);
@@ -1994,7 +1994,7 @@ Context control:\n\
       printf (_("\
 When FILE is '-', read standard input.  With no FILE, read '.' if\n\
 recursive, '-' otherwise.  With fewer than two FILEs, assume -h.\n\
-Exit status is 0 if any line is selected, 1 otherwise;\n\
+Exit status is 0 if any line (or file if -L) is selected, 1 otherwise;\n\
 if any error occurs and -q is not given, the exit status is 2.\n"));
       emit_bug_reporting_address ();
     }
diff --git a/tests/skip-read b/tests/skip-read
index 1eef87e..3c32c48 100755
--- a/tests/skip-read
+++ b/tests/skip-read
@@ -15,7 +15,7 @@ for opts in '-m0 y' '-f /dev/null' '-v ""'; do
       eval returns_ 1 grep -l $opts $matcher /dev/null > out || fail=1
       compare /dev/null out || fail=1
     done
-    eval returns_ 1 grep -L $opts $matcher /dev/null > out || fail=1
+    eval grep -L $opts $matcher /dev/null > out || fail=1
     compare exp out || fail=1
   done
 done

-----------------------------------------------------------------------

Summary of changes:
 NEWS            | 5 +++++
 doc/grep.texi   | 3 +++
 gnulib          | 2 +-
 src/grep.c      | 6 +++---
 tests/skip-read | 2 +-
 5 files changed, 13 insertions(+), 5 deletions(-)


hooks/post-receive
-- 
grep



reply via email to

[Prev in Thread] Current Thread [Next in Thread]