Talk About Quality

Tom Harris

AWK scripts

leave a comment »

Stronger than sed. Simpler than perl. Less popular than python. Learn awk!

Problem: My compiler doesn’t have a warnings-as-errors flag but I need one

Solution: Add this to the end of the compiler’s make command

2>&1 | awk ‘BEGIN {warnings = 0} /warning:/ {print; warnings++} END {exit(warnings)}’

Notes:

If your compiler’s warnings have a different format, change the /regular expression/ to match!

Bonus Question:

There is one problem with this method. Can you spot it?

Written by Tom Harris

October 26, 2007 at 3:09 pm

Leave a comment