RosettaCodeData/Task/Assertions/UNIX-Shell/assertions.sh

12 lines
213 B
Bash
Raw Permalink Normal View History

2015-02-20 00:35:01 -05:00
assert() {
if test ! $1; then
[[ $2 ]] && echo "$2" >&2
exit 1
fi
}
x=42
assert "$x -eq 42" "that's not the answer"
((x--))
assert "$x -eq 42" "that's not the answer"
echo "won't get here"