This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

check_GNU_style.sh: Don't cat empty file


Hi,

committed as obvious.

Thanks,
- Tom
check_GNU_style.sh: Don't cat empty file

2015-05-18  Tom de Vries  <tom@codesourcery.com>

	* check_GNU_style.sh (g, ag, vg): Don't cat empty file.
---
 contrib/check_GNU_style.sh | 30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/contrib/check_GNU_style.sh b/contrib/check_GNU_style.sh
index 728c11a..ab59b1e 100755
--- a/contrib/check_GNU_style.sh
+++ b/contrib/check_GNU_style.sh
@@ -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 (){
-- 
1.9.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]