[PATCH] tests: use "returns_" rather than explicit comparison with "$?"
From:
Jim Meyering
Subject:
[PATCH] tests: use "returns_" rather than explicit comparison with "$?"
Date:
Sat, 12 Nov 2016 18:38:04 -0800
I noticed many tests that compare directly with "$?". However, we now
have the "returns_" function (from init.sh) that can be used to make
the resulting code a little less error-prone: all on one line/stmt, it
is harder to accidentally insert code that accidentally clobbers "$?".
Here's an example of what most of these changes look like:
-ls -l --time-style=XX > out 2> err
-test $? = 2 || fail=1
+returns_ 2 ls -l --time-style=XX > out 2> err || fail=1