check_GNU_style.sh: Don't cat empty file

Tom de Vries Tom_deVries@mentor.com
Mon May 18 09:01:00 GMT 2015


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



More information about the Gcc-patches mailing list