]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
ldns-compare-zones exits 2 on diff with -e
authorWillem Toorop <willem@nlnetlabs.nl>
Tue, 4 Mar 2014 22:06:19 +0000 (23:06 +0100)
committerWillem Toorop <willem@nlnetlabs.nl>
Tue, 4 Mar 2014 22:06:19 +0000 (23:06 +0100)
Changelog
examples/ldns-compare-zones.1
examples/ldns-compare-zones.c

index 4e3bd20ac8b20f9d0d799ec9bc7c1510b89e6313..0fb09b25f39dbc1ab633934655b7d4302501e161 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -5,6 +5,7 @@ TBD
        * Fix #551 change Regent to Copyright holder in BSD license in
          some of the headings of the file, to match the opensource.org
          BSD license.
+       * -e option makes ldns-compare-zones exit with status code 2 on difference
 
 1.6.17 2014-01-10
        * Fix ldns_dnssec_zone_new_frm_fp_l to allow the last parsed line of a
index facccd874562e180479ce0c7303ff3366cda278a..7ac69ddfa57cb0870a791ae82eeb85b6324a2129 100644 (file)
@@ -42,6 +42,9 @@ Do not exclude the SOA record from the comparison.  The SOA record may
 then show up as changed due to a new serial number.  Off by default since
 you may be interested to know if (other zone apex elements) have changed.
 .TP
+\fB-e\fR
+Exit with status code 2 when zones differ.
+.TP
 \fB-h\fR
 Show usage and exit
 .TP
index a39c4b80c607b28dcf9b46d7e025b7b2524fd65d..514bcb258d843f1b5b8b7560e9536acc43e56a66 100644 (file)
 static void 
 usage(char *prog)
 {
-       printf("Usage: %s [-v] [-i] [-d] [-c] [-s] <zonefile1> <zonefile2>\n",
-               prog);
+       printf("Usage: %s [-v] [-i] [-d] [-c] [-s] [-e] "
+              "<zonefile1> <zonefile2>\n", prog);
        printf("       -i - print inserted\n");
        printf("       -d - print deleted\n");
        printf("       -c - print changed\n");
        printf("       -a - print all differences (-i -d -c)\n");
        printf("       -s - do not exclude SOA record from comparison\n");
        printf("       -z - do not sort zones\n");
+       printf("       -e - exit with status 2 on changed zones\n");
        printf("       -h - show usage and exit\n");
        printf("       -v - show the version and exit\n");
 }
@@ -54,9 +55,10 @@ main(int argc, char **argv)
        int             c;
        bool            opt_deleted = false, opt_inserted = false, opt_changed = false;
         bool           sort = true, inc_soa = false;
+       bool            opt_exit_status = false;
        char            op = 0;
 
-       while ((c = getopt(argc, argv, "ahvdicsz")) != -1) {
+       while ((c = getopt(argc, argv, "ahvdicesz")) != -1) {
                switch (c) {
                case 'h':
                        usage(argv[0]);
@@ -69,6 +71,9 @@ main(int argc, char **argv)
                                  ldns_version());
                        exit(EXIT_SUCCESS);
                        break;
+               case 'e':
+                       opt_exit_status = true;
+                       break;
                case 's':
                        inc_soa = true;
                        break;
@@ -281,5 +286,5 @@ main(int argc, char **argv)
        ldns_zone_deep_free(z2);
        ldns_zone_deep_free(z1);
 
-       return 0;
+       return opt_exit_status && (num_ins || num_del || num_chg) ? 2 : 0;
 }