From 908b69a476659a18ea097a8165fcf4ca1e8c50ed Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 20 Oct 2020 21:43:50 -0400 Subject: [PATCH] Drop the "-x" flag. The "-x" flag used to set the exit code non-zero on error, thus making it easier to detect errors in shell scripts. But I can imagine no situation where returning zero unconditionally is preferable; and so, I've removed the flag and enabled the "-x" behavior by default. --- CHANGES | 1 + README | 12 ++++-------- valtz | 13 ++++++------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/CHANGES b/CHANGES index b2afc90..73534c7 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,7 @@ Changes from version 0.7 ======================== +* Dropped "-x" flag; the return code is always non-zero on error now. * Warn about IP addresses in hostname fields * Add support for SRV records * Allow underscore characters in FQDNs and pointers diff --git a/README b/README index 508878d..1bbee15 100644 --- a/README +++ b/README @@ -6,16 +6,16 @@ Validation tool for tinydns-data zone files. Usage: Simple validation: - valtz [-qrRix] + valtz [-qrRi] Simple filtering: - valtz -f[qrRiItTx] + valtz -f[qrRiItT] Extensive filtering: - valtz -F[qrRiItTx] + valtz -F[qrRiItT] General usage: - valtz [-hfFqrRiItTx] + valtz [-hfFqrRiItT] -h shows this help. @@ -86,10 +86,6 @@ General usage: A commandline way to explicitly set the allowed recordtypes. This is _concatenated_ to the allowtype-allowed recordtypes. - -x Exit with non-null exit code on errors; i.e. make errors detectable by - e.g. shell scripts; 1 = validation error, 2 = permission error, - 3 = combination of 1 and 2. - All errors in the zonefiles are sent to STDERR. diff --git a/valtz b/valtz index 0ca0e6a..adefae8 100755 --- a/valtz +++ b/valtz @@ -48,14 +48,17 @@ my $COPYRIGHT = '; (C) 2003 Magnus Bodin, http://x42.com/software/'; $| = 1; my %opt; -getopts('?fFhHiIqrRstT:x', \%opt); +getopts('?fFhHiIqrRstT:', \%opt); my $FILESUFFIXREGEXP = '('.join('|', qw/ ,v ~ .bak .log .old .swp .tmp /).')$'; +# Validation errors my $verrs_total = 0; + +# "Permission" errors with respect to what record types are allowed my $perrs_total = 0; @@ -899,7 +902,7 @@ if ($opt{h} || $opt{H} || $opt{'?'}) valtz $VERSION, $COPYRIGHT validates tinydns-data zone files Usage: - $0 [-hfFqrRiItTx] + $0 [-hfFqrRiItT] -h shows this help. @@ -970,10 +973,6 @@ Usage: A commandline way to explicitly set the allowed recordtypes. This is _concatenated_ to the allowtype-allowed recordtypes. - -x Exit with non-null exit code on errors; i.e. make errors detectable by - e.g. shell scripts; 1 = validation error, 2 = permission error, - 3 = combination of 1 and 2. - All errors in the zonefiles are sent to STDERR. @@ -1112,7 +1111,7 @@ else } } -if ($opt{x} && ($verrs_total + $perrs_total)) +if ($verrs_total + $perrs_total) { my $exitcode = $verrs_total > 0 ? 1 : 0; $exitcode += $perrs_total > 0 ? 2 : 0; -- 2.44.2