check_GNU_style.sh: Don't cat empty file
authorTom de Vries <tom@codesourcery.com>
Mon, 18 May 2015 07:07:44 +0000 (07:07 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Mon, 18 May 2015 07:07:44 +0000 (07:07 +0000)
2015-05-18  Tom de Vries  <tom@codesourcery.com>

* check_GNU_style.sh (g, ag, vg): Don't cat empty file.

From-SVN: r223284

contrib/ChangeLog
contrib/check_GNU_style.sh

index 1ab3fdf858b1ec468e5064b7f5af2733a26a72ec..8276c9866d9557f868a5d9f6db890b6b883dcdb1 100644 (file)
@@ -1,3 +1,7 @@
+2015-05-18  Tom de Vries  <tom@codesourcery.com>
+
+       * check_GNU_style.sh (g, ag, vg): Don't cat empty file.
+
 2015-05-18  Tom de Vries  <tom@codesourcery.com>
 
        * check_GNU_style.sh (g, ag, vg, col): Declare local vars with local.
index 728c11a691d8510b08556ac07cd0071dbe328eef..ab59b1e6fc0317f2c7e49b081337a7f990feaad9 100755 (executable)
@@ -84,10 +84,16 @@ grep $format '^+' $files \
 g (){
     local msg="$1"
     local arg="$2"
+
+    local found=false
     cat $inp \
        | egrep --color=always -- "$arg" \
-       > $tmp && printf "\n$msg\n"
-    cat $tmp
+       > "$tmp" && found=true
+
+    if $found; then
+       printf "\n$msg\n"
+       cat "$tmp"
+    fi
 }
 
 # And Grep
@@ -95,11 +101,17 @@ ag (){
     local msg="$1"
     local arg1="$2"
     local arg2="$3"
+
+    local found=false
     cat $inp \
        | egrep --color=always -- "$arg1" \
        | egrep --color=always -- "$arg2" \
-       > $tmp && printf "\n$msg\n"
-    cat $tmp
+       > "$tmp" && found=true
+
+    if $found; then
+       printf "\n$msg\n"
+       cat "$tmp"
+    fi
 }
 
 # reVerse Grep
@@ -107,11 +119,17 @@ vg (){
     local msg="$1"
     local varg="$2"
     local arg="$3"
+
+    local found=false
     cat $inp \
        | egrep -v -- "$varg" \
        | egrep --color=always -- "$arg" \
-       > $tmp && printf "\n$msg\n"
-    cat $tmp
+       > "$tmp" && found=true
+
+    if $found; then
+       printf "\n$msg\n"
+       cat "$tmp"
+    fi
 }
 
 col (){