From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13140 invoked by alias); 18 May 2015 07:19:32 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 13128 invoked by uid 89); 18 May 2015 07:19:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 18 May 2015 07:19:30 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-02.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1YuFKg-0001Di-Mf from Tom_deVries@mentor.com for gcc-patches@gcc.gnu.org; Mon, 18 May 2015 00:19:27 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-02.mgc.mentorg.com (137.202.0.106) with Microsoft SMTP Server id 14.3.224.2; Mon, 18 May 2015 08:19:25 +0100 Message-ID: <5559927B.4090305@mentor.com> Date: Mon, 18 May 2015 07:31:00 -0000 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: GCC Patches Subject: check_GNU_style.sh: Don't cat empty file Content-Type: multipart/mixed; boundary="------------040607090305080008010207" X-SW-Source: 2015-05/txt/msg01531.txt.bz2 --------------040607090305080008010207 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-length: 42 Hi, committed as obvious. Thanks, - Tom --------------040607090305080008010207 Content-Type: text/x-patch; name="0003-check_GNU_style.sh-Don-t-cat-empty-file.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0003-check_GNU_style.sh-Don-t-cat-empty-file.patch" Content-length: 1468 check_GNU_style.sh: Don't cat empty file 2015-05-18 Tom de Vries * 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 --------------040607090305080008010207--