Use standard error/warning message format in the unifier script
authorPeter Kovacs <kpeter@inf.elte.hu>
Tue, 28 Oct 2008 15:37:46 +0100
changeset 341f8832dc16d45
parent 339 2593e163e407
child 342 3e906e6c08a9
Use standard error/warning message format in the unifier script
scripts/unify-sources.sh
     1.1 --- a/scripts/unify-sources.sh	Thu Jun 19 17:33:06 2008 +0100
     1.2 +++ b/scripts/unify-sources.sh	Tue Oct 28 15:37:46 2008 +0100
     1.3 @@ -86,25 +86,35 @@
     1.4  }
     1.5  
     1.6  function check_action() {
     1.7 +    if [ "$3" == 'tabs' ]
     1.8 +    then
     1.9 +        PATTERN=$(echo -e '\t')
    1.10 +    elif [ "$3" == 'trailing spaces' ]
    1.11 +    then
    1.12 +        PATTERN='\ +$'
    1.13 +    else
    1.14 +        PATTERN='*'
    1.15 +    fi
    1.16 +
    1.17      if ! diff -q $1 $2 >/dev/null
    1.18      then
    1.19 -	echo
    1.20 -	echo -n "      $3 failed at line(s): "
    1.21 -	echo -n $(diff $1 $2 | grep '^[0-9]' | sed "s/^\(.*\)c.*$/ \1/g" | 
    1.22 -	          sed "s/,/-/g" | paste -s -d',')
    1.23 -	FAILED=YES
    1.24 +        if [ "$PATTERN" == '*' ]
    1.25 +        then
    1.26 +            diff $1 $2 | grep '^[0-9]' | sed "s|^\(.*\)c.*$|$2:\1: check failed: $3|g" |
    1.27 +              sed "s/:\([0-9]*\),\([0-9]*\):\(.*\)$/:\1:\3 (until line \2)/g"
    1.28 +        else
    1.29 +            grep -n -E "$PATTERN" $2 | sed "s|^\([0-9]*\):.*$|$2:\1: check failed: $3|g"
    1.30 +        fi
    1.31 +        FAILED=YES
    1.32      fi
    1.33  }
    1.34  
    1.35  function check_warning() {
    1.36 -    echo
    1.37      if [ "$2" == 'long lines' ]
    1.38      then
    1.39 -        echo -n "      $2 warning at line(s): "
    1.40 -        echo -n $(grep -n -E '.{81,}' $1 | sed "s/^\([0-9]*\)/ \1\t/g" | 
    1.41 -                  cut -f 1 | paste -s -d',')
    1.42 +        grep -n -E '.{81,}' $1 | sed "s|^\([0-9]*\):.*$|$1:\1: warning: $2|g"
    1.43      else
    1.44 -        echo -n "      $2 warning"
    1.45 +        echo "$1: warning: $2"
    1.46      fi
    1.47      WARNED=YES
    1.48  }
    1.49 @@ -236,7 +246,12 @@
    1.50  # process the file
    1.51  
    1.52  function process_file() {
    1.53 -    echo -n "    $ACTION $1..."
    1.54 +    if [ "$ACTION" == 'update' ]
    1.55 +    then
    1.56 +        echo -n "    $ACTION $1..."
    1.57 +    else
    1.58 +        echo "	  $ACTION $1..."
    1.59 +    fi
    1.60  
    1.61      CHECKING="header tabs spaces long_lines"
    1.62  
    1.63 @@ -246,7 +261,10 @@
    1.64  	"$check"_check $1
    1.65      done
    1.66      "$ACTION"_end $1
    1.67 -    echo
    1.68 +    if [ "$ACTION" == 'update' ]
    1.69 +    then
    1.70 +        echo
    1.71 +    fi
    1.72  }
    1.73  
    1.74  function process_all {