]> Dogcows Code - chaz/tar/blobdiff - src/tar.c
Avoid overwriting exit_status with a value indicating less important condition.
[chaz/tar] / src / tar.c
index 583edc90ea6f549e883186d097f10c496a97bd8e..055746188cd55b029d2026deb4ece99a17d148bb 100644 (file)
--- a/src/tar.c
+++ b/src/tar.c
@@ -2577,7 +2577,7 @@ main (int argc, char **argv)
   if (stdlis == stdout)
     close_stdout ();
   else if (ferror (stderr) || fclose (stderr) != 0)
-    exit_status = TAREXIT_FAILURE;
+    set_exit_status (TAREXIT_FAILURE);
 
   return exit_status;
 }
@@ -2615,3 +2615,13 @@ tar_timespec_cmp (struct timespec a, struct timespec b)
     a.tv_nsec = b.tv_nsec = 0;
   return timespec_cmp (a, b);
 }
+
+/* Set tar exit status to VAL, unless it is already indicating
+   a more serious condition. This relies on the fact that the
+   values of TAREXIT_ constants are ranged by severity. */
+void
+set_exit_status (int val)
+{
+  if (val > exit_status)
+    exit_status = val;
+}
This page took 0.020056 seconds and 4 git commands to generate.