2 # This file is part of NIT ( http://www.nitlanguage.org ).
4 # Copyright 2008 Jean Privat <jean@pryen.org>
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
19 # showerr.sh [filelocation]...
21 # Show an colorize lines locations (with or without error messages) passed in arguments.
22 # If no arguments are given, line locations a read for the standard input (one per line)
24 red
=$
(printf "\033[0;31m")
25 bred
=$
(printf "\033[1;31m")
26 green
=$
(printf "\033[0;32m")
27 yellow
=$
(printf "\033[0;33m")
28 def
=$
(printf "\033[0m")
35 sed -e
"s!^$F:$D,$D--$D,$D: $M!X \1 \2 \3 \4 \5 \6!" \
36 -e
"s!^$F:$D,$D--$D: $M!X \1 \2 \3 \2 \4 \5!" \
37 -e
"s!^$F:$D,$D: $M!X \1 \2 \3 \2 \3 \4!" \
38 -e
"s!^$F:$D: $M!X \1 \2 1 \2 eol \3!" \
39 -e
"s!^$F:$D\$!X \1 \2 1 \2 eol!" |
40 while read k f l1 c1 l2 c2 m
; do
41 if [ "$k" != "X" ]; then
42 echo "$k $f $l1 $c1 $l2 $c2 $m"
44 # Colorize and rewrite the error message
46 sed -e
"s!^\(Warning:\)\(.*\)!$green\1$def\2!" \
47 -e
"s!^\([^:]*[Ee]rror:\)\(.*\)!$bred\1$def\2!"
49 echo "$yellow$f$def:$l1,$c1--$l2,$c2: $m"
51 # Colorize and show the line
55 start
="\(.\{$(($c1-1))\}\)"
57 if [ $l1 = $l2 ]; then
58 if [ $c2 = eol
]; then
62 len
="\(.\{$(($c2 - $c1 + 1))\}\)"
64 sed -n
-e
"${l1}s!^$start$len\(.*\)! \1$red\2$def\3!p" $f
69 start2
="\(.\{$(($c2-1))\}\)"
71 # Show only the first line
72 sed -n
-e
"${l1}s!^$start\(.*\)! \1$red\2 (...)$def!p" $f
73 #sed -n -e "${l1}s!^$start\(.*\)! \1$red\2!p" $f
74 #if [ $l1 = $(($l2-2)) ]; then
75 # sed -n -e "$(($l1+1))s!^\(.*\)! \1!p" $f
76 #elif [ $l1 != $(($l2-1)) ]; then
77 # sed -n -e "${l1}s!^\([ ]*\).*! \1...!p" $f
79 #sed -n -e "${l2}s!^$start2\(.*\)! \1$def\2!p" $f