From 1ec36ebc97a6c546d1ef0acc545d4636d36b89a1 Mon Sep 17 00:00:00 2001 From: Justin Davis Date: Thu, 1 Sep 2011 16:33:54 -0400 Subject: Ignore whitespace and add better error reporting for bad input. --- bin/pbjparse.awk | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/bin/pbjparse.awk b/bin/pbjparse.awk index 8ba5372..be75811 100755 --- a/bin/pbjparse.awk +++ b/bin/pbjparse.awk @@ -83,15 +83,13 @@ function parsepbj ( cmd) # cmd is a "local" var tcmd = joinfields(2) templates[++templcount] = tcmd } - else if ($1 == "") ; # ignore blank lines - else { - print "ignoring line " FNR ": " $0 | "cat 1>&2" - } + else if ($1 ~ /^[ \t]*$/) ; # ignore lines of whitespace + else die("invalid input: " $0) } function die (msg) { - printf "%s:%s.%d:%s\n", PROG, FILENAME, FNR, msg | "cat 1>&2" + printf "%s: error: %s:%d %s\n", PROG, FILENAME, FNR, msg | "cat 1>&2" exit 1 } -- cgit v1.2.3-24-g4f1b