[isomd5sum 2/2] Add exit code 2 for user abort (#907600)

Brian C. Lane bcl at redhat.com
Thu Feb 21 14:33:08 UTC 2013


From: "Brian C. Lane" <bcl at redhat.com>

---
 checkisomd5.1 |  2 +-
 checkisomd5.c | 11 ++++++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/checkisomd5.1 b/checkisomd5.1
index 78a3fa1..46d19f1 100644
--- a/checkisomd5.1
+++ b/checkisomd5.1
@@ -11,7 +11,7 @@ This manual page documents briefly the \fBcheckisomd5\fR command.  \fBcheckisomd
 The check can be aborted by pressing Esc key.
 .SH "EXIT STATUS"
 .PP
-Program returns exit status 0 if the checksum is correct, or 1 if the checksum is incorrect, non-existent, or check was aborted.
+Program returns exit status 0 if the checksum is correct, 1 if the checksum is incorrect, non-existent, or 2 if the check was aborted.
 .SH "OPTIONS"
 .IP "\fB\-\-md5sumonly\fP" 10
 Do not check the target.  Instead, output human-readable information about the target's checksums.
diff --git a/checkisomd5.c b/checkisomd5.c
index 98c01d8..d08c009 100644
--- a/checkisomd5.c
+++ b/checkisomd5.c
@@ -79,34 +79,43 @@ static void usage(void) {
 
 
 /* Process the result code and return the proper exit status value
+ *
+ * return 1 for failures, 0 for good checksum and 2 if aborted.
  */
 int processExitStatus(int rc) {
     char * result;
+    int exit_rc;
 
     switch (rc) {
         case ISOMD5SUM_CHECK_FAILED:
             result = "FAIL.\n\nIt is not recommended to use this media.";
+            exit_rc = 1;
             break;
         case ISOMD5SUM_CHECK_ABORTED:
             result = "UNKNOWN.\n\nThe media check was aborted.";
+            exit_rc = 2;
             break;
         case ISOMD5SUM_CHECK_NOT_FOUND:
             result = "NA.\n\nNo checksum information available, unable to verify media.";
+            exit_rc = 1;
             break;
         case ISOMD5SUM_FILE_NOT_FOUND:
             result = "NA.\n\nFile not found.";
+            exit_rc = 1;
             break;
         case ISOMD5SUM_CHECK_PASSED:
             result = "PASS.\n\nIt is OK to use this media.";
+            exit_rc = 0;
             break;
         default:
             result = "checkisomd5 ERROR - bad return value";
+            exit_rc = 1;
             break;
     }
 
     fprintf(stderr, "\nThe media check is complete, the result is: %s\n", result);
 
-    return(rc != ISOMD5SUM_CHECK_PASSED);
+    return(exit_rc);
 }
 
 
-- 
1.8.1



More information about the anaconda-patches mailing list