* check_GNU_style.sh: Don't cat empty file
@ 2015-05-18 7:31 Tom de Vries
2015-05-18 8:41 ` Andreas Schwab
0 siblings, 1 reply; 3+ messages in thread
From: Tom de Vries @ 2015-05-18 7:31 UTC (permalink / raw)
To: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 42 bytes --]
Hi,
committed as obvious.
Thanks,
- Tom
[-- Attachment #2: 0003-check_GNU_style.sh-Don-t-cat-empty-file.patch --]
[-- Type: text/x-patch, Size: 1468 bytes --]
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: check_GNU_style.sh: Don't cat empty file
2015-05-18 7:31 check_GNU_style.sh: Don't cat empty file Tom de Vries
@ 2015-05-18 8:41 ` Andreas Schwab
2015-05-18 9:01 ` Tom de Vries
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2015-05-18 8:41 UTC (permalink / raw)
To: Tom de Vries; +Cc: GCC Patches
Tom de Vries <Tom_deVries@mentor.com> writes:
> 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
cat $inp \
| egrep --color=always -- "$arg" \
> $tmp && {
printf "\n$msg\n"
cat $tmp
}
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: check_GNU_style.sh: Don't cat empty file
2015-05-18 8:41 ` Andreas Schwab
@ 2015-05-18 9:01 ` Tom de Vries
0 siblings, 0 replies; 3+ messages in thread
From: Tom de Vries @ 2015-05-18 9:01 UTC (permalink / raw)
To: Andreas Schwab; +Cc: GCC Patches, Jeff Law
On 18-05-15 10:31, Andreas Schwab wrote:
> Tom de Vries <Tom_deVries@mentor.com> writes:
>
>> 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
>
> cat $inp \
> | egrep --color=always -- "$arg" \
> > $tmp && {
> printf "\n$msg\n"
> cat $tmp
> }
>
Hi Andreas,
yep, that's another and indeed shorter way to do the same.
I prefer the committed version though, with a variable name making explicit what
the '&&' situation means, and handling that situation in a separate statement.
Thanks,
- Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-05-18 8:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-18 7:31 check_GNU_style.sh: Don't cat empty file Tom de Vries
2015-05-18 8:41 ` Andreas Schwab
2015-05-18 9:01 ` Tom de Vries
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).