freebsd-dev/contrib/awk/awklib/eg/lib/assert.awk
2000-08-15 10:02:07 +00:00

19 lines
376 B
Awk

# assert --- assert that a condition is true. Otherwise exit.
# Arnold Robbins, arnold@gnu.org, Public Domain
# May, 1993
function assert(condition, string)
{
if (! condition) {
printf("%s:%d: assertion failed: %s\n",
FILENAME, FNR, string) > "/dev/stderr"
_assert_exit = 1
exit 1
}
}
END {
if (_assert_exit)
exit 1
}