Code

Introduce sane_unset and use it to ensure proper && chaining
[git.git] / t / test-lib.sh
index d86edcd7a62ff9e12aba72259d5927a7a7e2eeaa..87308f5a9bb8086475dbc49276b8ad249f196d32 100644 (file)
@@ -268,6 +268,17 @@ remove_cr () {
        tr '\015' Q | sed -e 's/Q$//'
 }
 
+# In some bourne shell implementations, the "unset" builtin returns
+# nonzero status when a variable to be unset was not set in the first
+# place.
+#
+# Use sane_unset when that should not be considered an error.
+
+sane_unset () {
+       unset "$@"
+       return 0
+}
+
 test_tick () {
        if test -z "${test_tick+set}"
        then