From: Willem Toorop Date: Tue, 4 Mar 2014 22:06:19 +0000 (+0100) Subject: ldns-compare-zones exits 2 on diff with -e X-Git-Tag: release-1.7.0-rc1~161^2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a31a8b1c200b1dae6d986e41daa22eecd5bef2e;p=thirdparty%2Fldns.git ldns-compare-zones exits 2 on diff with -e --- diff --git a/Changelog b/Changelog index 4e3bd20a..0fb09b25 100644 --- 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 diff --git a/examples/ldns-compare-zones.1 b/examples/ldns-compare-zones.1 index facccd87..7ac69ddf 100644 --- a/examples/ldns-compare-zones.1 +++ b/examples/ldns-compare-zones.1 @@ -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 diff --git a/examples/ldns-compare-zones.c b/examples/ldns-compare-zones.c index a39c4b80..514bcb25 100644 --- a/examples/ldns-compare-zones.c +++ b/examples/ldns-compare-zones.c @@ -25,14 +25,15 @@ static void usage(char *prog) { - printf("Usage: %s [-v] [-i] [-d] [-c] [-s] \n", - prog); + printf("Usage: %s [-v] [-i] [-d] [-c] [-s] [-e] " + " \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; }