AWK scripts
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?
Leave a Reply