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?

Advertisement

Written by Tom Harris

October 26, 2007 at 3:09 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: