Tipp: make-Ausgaben abkürzen (stderr->stdout), Grep/RegEx

Direkte Linux-Programmierung, POSIX
Antworten
Benutzeravatar
Xin
nur zu Besuch hier
Beiträge: 8858
Registriert: Fr Jul 04, 2008 11:10 pm
Wohnort: /home/xin
Kontaktdaten:

Tipp: make-Ausgaben abkürzen (stderr->stdout), Grep/RegEx

Beitrag von Xin » So Jun 09, 2013 3:01 pm

Ich bin derzeit mal wieder damit beschäftigt, mich mit clang auseinander zu setzen. Um ein Verzeichnis zu kompilieren erhalte ich noch einiges an Fehlermeldungen:

Code: Alles auswählen

xin@trinity:~/xsd/de/xsd/block$ make compile
clang | background (de/xsd/block).....
clang | connector (de/xsd/block).....
clang | design (de/xsd/block).....
In file included from ../../../de/xsd/block/design.cpp:13:
../../../de/xsd/doc/viewdoc.h:102:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

../../../de/xsd/block/design.cpp:325:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

2 warnings generated.
clang | element (de/xsd/block).....
In file included from ../../../de/xsd/block/element.cpp:6:
../../../de/xsd/doc/viewdoc.h:102:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

../../../de/xsd/block/element.cpp:767:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

2 warnings generated.
clang | elementfactory (de/xsd/block).....
In file included from ../../../de/xsd/block/elementfactory.cpp:28:
In file included from ../../../de/xsd/block/element/slider.h:5:
In file included from ../../../de/xsd/dataviewer/runtimeslider.h:4:
In file included from ../../../de/xsd/dataviewer/runtimeelement.h:4:
../../../de/xsd/dataviewer/runtimeelementlist.h:28:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

In file included from ../../../de/xsd/block/elementfactory.cpp:28:
In file included from ../../../de/xsd/block/element/slider.h:5:
In file included from ../../../de/xsd/dataviewer/runtimeslider.h:4:
../../../de/xsd/dataviewer/runtimeelement.h:26:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

In file included from ../../../de/xsd/block/elementfactory.cpp:28:
In file included from ../../../de/xsd/block/element/slider.h:5:
../../../de/xsd/dataviewer/runtimeslider.h:35:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

In file included from ../../../de/xsd/block/elementfactory.cpp:29:
In file included from ../../../de/xsd/block/element/updatebutton.h:8:
../../../de/xsd/dataviewer/runtimebutton.h:33:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

4 warnings generated.
clang | elementlist (de/xsd/block).....
clang | value (de/xsd/block).....
clang | valuerequest (de/xsd/block).....
clang | wire (de/xsd/block).....
clang | wiretype (de/xsd/block).....
clang | bitcube (de/xsd/block/element).....
clang | bitmapfilter (de/xsd/block/element).....
clang | boolean (de/xsd/block/element).....
clang | cast (de/xsd/block/element).....
clang | color (de/xsd/block/element).....
clang | constvalue (de/xsd/block/element).....
clang | coutput (de/xsd/block/element).....
clang | crosshairs (de/xsd/block/element).....
clang | cubeaccessfilter (de/xsd/block/element).....
clang | cubelayerfilter (de/xsd/block/element).....
clang | dim3d (de/xsd/block/element).....
clang | dimvalue (de/xsd/block/element).....
clang | display (de/xsd/block/element).....
clang | filter_bcut (de/xsd/block/element).....
In file included from ../../../../de/xsd/block/element/constvalue.cpp:5:
../../../../de/xsd/math/constants.h:19:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

1 warning generated.
clang | filter_brightness (de/xsd/block/element).....
clang | filter_contrast (de/xsd/block/element).....
In file included from ../../../../de/xsd/block/element/dimvalue.cpp:8:
../../../../de/xsd/gtk/pangotext.h:43:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

clang | filter_gamma (de/xsd/block/element).....
clang | float (de/xsd/block/element).....
1 warning generated.
clang | guislider (de/xsd/block/element).....
clang | if (de/xsd/block/element).....
clang | iloop (de/xsd/block/element).....
clang | integer (de/xsd/block/element).....
clang | logarithmfilter (de/xsd/block/element).....
clang | logger (de/xsd/block/element).....
In file included from ../../../../de/xsd/block/element/iloop.cpp:4:
In file included from ../../../../de/xsd/dataviewer/mainview.h:8:
../../../../de/xsd/doc/viewdoc.h:102:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

In file included from ../../../../de/xsd/block/element/iloop.cpp:4:
In file included from ../../../../de/xsd/dataviewer/mainview.h:13:
../../../../de/xsd/dataviewer/runtimeelementlist.h:28:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

In file included from ../../../../de/xsd/block/element/iloop.cpp:4:
In file included from ../../../../de/xsd/dataviewer/mainview.h:16:
In file included from ../../../../de/xsd/dataviewer/dataarea.h:6:
In file included from ../../../../de/xsd/gtk/buffereddrawingarea.h:6:
../../../../de/xsd/gtk/drawable.h:48:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

In file included from ../../../../de/xsd/block/element/iloop.cpp:4:
In file included from ../../../../de/xsd/dataviewer/mainview.h:16:
In file included from ../../../../de/xsd/dataviewer/dataarea.h:6:
../../../../de/xsd/gtk/buffereddrawingarea.h:101:27: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif // XSD_GTK_REQUIRED
                          ^
                                                                                                                                                                                              

In file included from ../../../../de/xsd/block/element/iloop.cpp:4:
In file included from ../../../../de/xsd/dataviewer/mainview.h:16:
../../../../de/xsd/dataviewer/dataarea.h:28:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

clang | mathcrossop (de/xsd/block/element).....
In file included from ../../../../de/xsd/block/element/guislider.cpp:4:
In file included from ../../../../de/xsd/dataviewer/mainview.h:8:
../../../../de/xsd/doc/viewdoc.h:102:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

In file included from ../../../../de/xsd/block/element/guislider.cpp:4:
In file included from ../../../../de/xsd/dataviewer/mainview.h:13:
../../../../de/xsd/dataviewer/runtimeelementlist.h:28:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

In file included from ../../../../de/xsd/block/element/guislider.cpp:4:
In file included from ../../../../de/xsd/dataviewer/mainview.h:16:
In file included from ../../../../de/xsd/dataviewer/dataarea.h:6:
In file included from ../../../../de/xsd/gtk/buffereddrawingarea.h:6:
../../../../de/xsd/gtk/drawable.h:48:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

In file included from ../../../../de/xsd/block/element/guislider.cpp:4:
In file included from ../../../../de/xsd/dataviewer/mainview.h:16:
In file included from ../../../../de/xsd/dataviewer/dataarea.h:6:
../../../../de/xsd/gtk/buffereddrawingarea.h:101:27: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif // XSD_GTK_REQUIRED
                          ^
                                                                                                                                                                                              

In file included from ../../../../de/xsd/block/element/guislider.cpp:4:
In file included from ../../../../de/xsd/dataviewer/mainview.h:16:
../../../../de/xsd/dataviewer/dataarea.h:28:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

clang | mathdecop (de/xsd/block/element).....
5 warnings generated.
clang | mathdivop (de/xsd/block/element).....
5 warnings generated.
clang | mathdotop (de/xsd/block/element).....
clang | mathdualop (de/xsd/block/element).....
clang | mathfunc1op (de/xsd/block/element).....
clang | mathfunc2op (de/xsd/block/element).....
clang | mathincop (de/xsd/block/element).....
clang | mathlog2op (de/xsd/block/element).....
clang | mathmulop (de/xsd/block/element).....
clang | mathplusop (de/xsd/block/element).....
clang | mathrotateop (de/xsd/block/element).....
clang | mathsingleop (de/xsd/block/element).....
clang | mathsubop (de/xsd/block/element).....
clang | mayoinput (de/xsd/block/element).....
clang | messagebox (de/xsd/block/element).....
clang | miscoloredfilter (de/xsd/block/element).....
clang | multiplexer (de/xsd/block/element).....
In file included from ../../../../de/xsd/block/element/mathrotateop.cpp:7:
../../../../de/xsd/math/constants.h:19:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

1 warning generated.
clang | phantom (de/xsd/block/element).....
clang | rawinput (de/xsd/block/element).....
clang | renderfilter (de/xsd/block/element).....
clang | rotatefilter (de/xsd/block/element).....
clang | slider (de/xsd/block/element).....
clang | source3d (de/xsd/block/element).....
clang | splitter (de/xsd/block/element).....
clang | string (de/xsd/block/element).....
clang | tiffinput (de/xsd/block/element).....
clang | tiffoutput (de/xsd/block/element).....
clang | unit3d (de/xsd/block/element).....
In file included from ../../../../de/xsd/block/element/slider.cpp:1:
In file included from ../../../../de/xsd/block/element/slider.h:5:
In file included from ../../../../de/xsd/dataviewer/runtimeslider.h:4:
In file included from ../../../../de/xsd/dataviewer/runtimeelement.h:4:
../../../../de/xsd/dataviewer/runtimeelementlist.h:28:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

In file included from ../../../../de/xsd/block/element/slider.cpp:1:
In file included from ../../../../de/xsd/block/element/slider.h:5:
In file included from ../../../../de/xsd/dataviewer/runtimeslider.h:4:
../../../../de/xsd/dataviewer/runtimeelement.h:26:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

In file included from ../../../../de/xsd/block/element/slider.cpp:1:
In file included from ../../../../de/xsd/block/element/slider.h:5:
../../../../de/xsd/dataviewer/runtimeslider.h:35:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

In file included from ../../../../de/xsd/block/element/slider.cpp:5:
../../../../de/xsd/doc/viewdoc.h:102:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

clang | updatebutton (de/xsd/block/element).....
4 warnings generated.
clang | valuerequest (de/xsd/block/element).....
clang | valuetype (de/xsd/block/element).....
clang | vector (de/xsd/block/element).....
clang | voxelcompiler (de/xsd/block/element).....
In file included from ../../../../de/xsd/block/element/updatebutton.cpp:1:
In file included from ../../../../de/xsd/block/element/updatebutton.h:8:
In file included from ../../../../de/xsd/dataviewer/runtimebutton.h:4:
In file included from ../../../../de/xsd/dataviewer/runtimeelement.h:4:
../../../../de/xsd/dataviewer/runtimeelementlist.h:28:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

In file included from ../../../../de/xsd/block/element/updatebutton.cpp:1:
In file included from ../../../../de/xsd/block/element/updatebutton.h:8:
In file included from ../../../../de/xsd/dataviewer/runtimebutton.h:4:
../../../../de/xsd/dataviewer/runtimeelement.h:26:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

In file included from ../../../../de/xsd/block/element/updatebutton.cpp:1:
In file included from ../../../../de/xsd/block/element/updatebutton.h:8:
../../../../de/xsd/dataviewer/runtimebutton.h:33:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

In file included from ../../../../de/xsd/block/element/updatebutton.cpp:5:
../../../../de/xsd/doc/viewdoc.h:102:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

4 warnings generated.
In file included from ../../../../de/xsd/block/element/valuetype.cpp:4:
../../../../de/xsd/gtk/pangotext.h:43:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
#endif
      ^
                                                                                                                                                                                              

1 warning generated.
clang | acos (de/xsd/block/icons).....
clang | add (de/xsd/block/icons).....
clang | asin (de/xsd/block/icons).....
clang | atan (de/xsd/block/icons).....
clang | bitcubecompressed (de/xsd/block/icons).....
clang | bitcube (de/xsd/block/icons).....
clang | bitmapdisplay (de/xsd/block/icons).....
clang | bitmapdisplay_cropped (de/xsd/block/icons).....
clang | bitmapdisplay_empty (de/xsd/block/icons).....
clang | cast_bool (de/xsd/block/icons).....
clang | cast (de/xsd/block/icons).....
clang | cast_float (de/xsd/block/icons).....
clang | cast_int (de/xsd/block/icons).....
clang | cos (de/xsd/block/icons).....
clang | coutput (de/xsd/block/icons).....
clang | cross (de/xsd/block/icons).....
clang | cubeaccessx (de/xsd/block/icons).....
clang | cubeaccessy (de/xsd/block/icons).....
clang | cubeaccessz (de/xsd/block/icons).....
clang | cubelayerfilter (de/xsd/block/icons).....
clang | decrement (de/xsd/block/icons).....
clang | divide (de/xsd/block/icons).....
clang | dot (de/xsd/block/icons).....
clang | e (de/xsd/block/icons).....
clang | exp (de/xsd/block/icons).....
clang | false (de/xsd/block/icons).....
clang | filereq (de/xsd/block/icons).....
clang | filter_bcut (de/xsd/block/icons).....
clang | filter_brightness (de/xsd/block/icons).....
clang | filter_contrast (de/xsd/block/icons).....
clang | filter_crop (de/xsd/block/icons).....
clang | filter_gamma (de/xsd/block/icons).....
clang | filter_log (de/xsd/block/icons).....
clang | filter_mcol (de/xsd/block/icons).....
clang | filter_rot (de/xsd/block/icons).....
clang | flyinput (de/xsd/block/icons).....
clang | flyoutput (de/xsd/block/icons).....
clang | flyoutput_create (de/xsd/block/icons).....
clang | iloop (de/xsd/block/icons).....
clang | increment (de/xsd/block/icons).....
clang | log10 (de/xsd/block/icons).....
clang | log (de/xsd/block/icons).....
clang | mayoinput (de/xsd/block/icons).....
clang | mayooutput (de/xsd/block/icons).....
clang | mayooutput_create (de/xsd/block/icons).....
clang | msgbox (de/xsd/block/icons).....
clang | multiplexer (de/xsd/block/icons).....
clang | multiplexer_image (de/xsd/block/icons).....
clang | multiplexer_noconnect (de/xsd/block/icons).....
clang | multiply (de/xsd/block/icons).....
clang | oprotate (de/xsd/block/icons).....
clang | phantom2d (de/xsd/block/icons).....
clang | phantom3d (de/xsd/block/icons).....
clang | pi (de/xsd/block/icons).....
clang | pow (de/xsd/block/icons).....
clang | render (de/xsd/block/icons).....
clang | scrollbar_x (de/xsd/block/icons).....
clang | scrollbar_y (de/xsd/block/icons).....
clang | scrollbar_z (de/xsd/block/icons).....
clang | sin (de/xsd/block/icons).....
clang | sqrt (de/xsd/block/icons).....
clang | sub (de/xsd/block/icons).....
clang | tan (de/xsd/block/icons).....
clang | tiffinput (de/xsd/block/icons).....
clang | tiffoutput (de/xsd/block/icons).....
clang | tiffoutput_create (de/xsd/block/icons).....
clang | true (de/xsd/block/icons).....
clang | voxelcompiler (de/xsd/block/icons).....
Viel Text, dabei interessiert mich eigentlich nur sehr wenig davon - nämlich die Zeilen in denen ein Warning oder ein Error vorkommt. Das meiste lässt sich damit nämlich bereits lösen.
Außerdem interessiert mich der Fortschritt, den mein MakeFile ausgibt in dem Moment auch nicht wirklich.

Leider kann man nach Warning oder Error nicht so einfach grepen. Eine entsprechende Expression muss her. Die sieht in dem Fall so aus:

Code: Alles auswählen

grep -E ":[0-9]*:[0-9]*: (error|warning)"
Ich suche nach einem String, der einen Doppelpunkt, gefolgt von Ziffern(Zeilennummer), Doppelpunkt, Spaltennummer (Ziffern), Doppelpunkt und nach einem Leerzeichen entweder das Wort "error" oder "warning" enthält.

Soweit so gut. Nun gibt clang die Fehler aber nicht an die Standard-Konsole (1) aus, die ich per Pipe greppen könnte, sondern an die Fehlerkonsole (2). Wir müssen also noch die Fehlerkonsole in die Standardkonsole umlenken. Das geht mit "2>&1".

Und so kommen wir zu einem kompletten Befehl:

Code: Alles auswählen

make compile 2>&1 | grep -E ":[0-9]*:[0-9]*: (error|warning)"
der eine übersichtliche Ausgabe erzeugt, die man schnell abarbeiten kann.

Code: Alles auswählen

../../../de/xsd/doc/viewdoc.h:102:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../de/xsd/block/design.cpp:325:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../de/xsd/doc/viewdoc.h:102:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../de/xsd/block/element.cpp:767:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../de/xsd/dataviewer/runtimeelementlist.h:28:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../de/xsd/dataviewer/runtimeelement.h:26:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../de/xsd/dataviewer/runtimeslider.h:35:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../de/xsd/dataviewer/runtimebutton.h:33:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../../de/xsd/math/constants.h:19:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../../de/xsd/gtk/pangotext.h:43:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../../de/xsd/doc/viewdoc.h:102:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../../de/xsd/dataviewer/runtimeelementlist.h:28:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../../de/xsd/gtk/drawable.h:48:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../../de/xsd/gtk/buffereddrawingarea.h:101:27: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../../de/xsd/dataviewer/dataarea.h:28:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../../de/xsd/doc/viewdoc.h:102:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../../de/xsd/dataviewer/runtimeelementlist.h:28:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../../de/xsd/gtk/drawable.h:48:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../../de/xsd/gtk/buffereddrawingarea.h:101:27: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../../de/xsd/dataviewer/dataarea.h:28:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../../de/xsd/math/constants.h:19:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../../de/xsd/dataviewer/runtimeelementlist.h:28:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../../de/xsd/dataviewer/runtimeelement.h:26:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../../de/xsd/dataviewer/runtimeslider.h:35:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../../de/xsd/doc/viewdoc.h:102:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../../de/xsd/dataviewer/runtimeelementlist.h:28:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../../de/xsd/dataviewer/runtimeelement.h:26:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../../de/xsd/dataviewer/runtimebutton.h:33:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../../de/xsd/doc/viewdoc.h:102:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
../../../../de/xsd/gtk/pangotext.h:43:7: warning: no newline at end of file [-pedantic,-Wnewline-eof]
Merke: Wer Ordnung hellt ist nicht zwangsläufig eine Leuchte.

Ich beantworte keine generellen Programmierfragen per PN oder Mail. Dafür ist das Forum da.

Antworten