coreutils
[Top][All Lists]
Advanced

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

[PATCH] maint: avoid new grep -q syntax-check


From: Pádraig Brady
Subject: [PATCH] maint: avoid new grep -q syntax-check
Date: Tue, 15 Nov 2022 13:31:32 +0000

* cfg.mk: Exclude NEWS from the check.
* init.cfg: s/grep -q/grep >/dev/null/.
* tests/ls/hyperlink.sh: Likewise.
* tests/ls/symlink-quote.sh: Likewise.
---
 cfg.mk                    | 10 +++++++---
 init.cfg                  |  2 +-
 tests/ls/hyperlink.sh     |  2 +-
 tests/ls/symlink-quote.sh |  2 +-
 4 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/cfg.mk b/cfg.mk
index 99a9ad4d3..992aabc86 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -599,8 +599,8 @@ sc_env_test_dependencies:
                grep -vF '[' |paste -d'|' -s))" tests | \
            sed "s/\([^:]\):.*env \([^)' ]*\).*/\1 \2/" | uniq | \
            while read test prog; do \
-             printf '%s' $$test | grep -q '\.pl$$' && continue; \
-             grep -q "print_ver_.* $$prog" $$test \
+             printf '%s' $$test | grep '\.pl$$' >/dev/null && continue; \
+             grep "print_ver_.* $$prog" $$test >/dev/null \
                || echo $$test should call: print_ver_ $$prog; \
            done | grep . && exit 1 || :
 
@@ -657,7 +657,7 @@ sc_prohibit_test_calls_print_ver_with_irrelevant_argument:
              while read file name; do                                  \
                for i in $$name; do                                     \
                  case "$$i" in install) i=ginstall;; esac;             \
-                 grep -w "$$i" $$file|grep -vw print_ver_|grep -q .    \
+                 grep -w "$$i" $$file|grep -vw print_ver_|grep . >/dev/null \
                    || { fail=1;                                        \
                         echo "*** Test: $$file, offending: $$i." 1>&2; };\
                done;                                                   \
@@ -906,6 +906,10 @@ 
exclude_file_name_regexp--sc_ensure_dblspace_after_dot_before_id_est = \.diff$$
 exclude_file_name_regexp--sc_ensure_comma_after_id_est = \.diff|$(_ll)$$
 exclude_file_name_regexp--sc_long_lines = \.diff$$|$(_ll)
 
+# `grep . -q` is not exactly equivalent to `grep . >/dev/null`
+# and this difference is significant in the NEWS description
+exclude_file_name_regexp--sc_unportable_grep_q = NEWS
+
 # Augment AM_CFLAGS to include our per-directory options:
 AM_CFLAGS += $($(@D)_CFLAGS)
 
diff --git a/init.cfg b/init.cfg
index eb57de264..576f6ecd6 100644
--- a/init.cfg
+++ b/init.cfg
@@ -636,7 +636,7 @@ mkfifo_or_skip_()
 
 trap_sigpipe_or_skip_()
 {
-  (trap '' PIPE && yes | :) 2>&1 | grep -qF 'Broken pipe' ||
+  (trap '' PIPE && yes | :) 2>&1 | grep -F 'Broken pipe' >/dev/null ||
     skip_ 'trapping SIGPIPE is not supported'
 }
 
diff --git a/tests/ls/hyperlink.sh b/tests/ls/hyperlink.sh
index e87b3cfe8..27c775777 100755
--- a/tests/ls/hyperlink.sh
+++ b/tests/ls/hyperlink.sh
@@ -29,7 +29,7 @@ encode() {
 
 ls_encoded() {
   ef=$(encode "$1")
-  echo "$ef" | grep -q 'dir$' && dir=: || dir=''
+  echo "$ef" | grep 'dir$' >/dev/null && dir=: || dir=''
   printf '\033]8;;file:///%s\a%s\033]8;;\a%s\n' \
     "$ef" "$1" "$dir"
 }
diff --git a/tests/ls/symlink-quote.sh b/tests/ls/symlink-quote.sh
index 688b9a4c1..43e1546d9 100755
--- a/tests/ls/symlink-quote.sh
+++ b/tests/ls/symlink-quote.sh
@@ -24,7 +24,7 @@ ln -s 'needs quoting' symlink || framework_failure_
 ls -l --quoting-style='shell-escape' symlink >out || fail=1
 
 # Coreutils v8.26 and 8.27 failed to quote the target name
-grep -q "symlink -> 'needs quoting'\$" out ||
+grep "symlink -> 'needs quoting'\$" out >/dev/null ||
   { cat out; fail=1; }
 
 Exit $fail
-- 
2.26.2




reply via email to

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