diff --git a/script/check_dnf_automatic b/script/check_dnf_automatic index 1d08a0c1428f61922b1d18ee80e2050ba502e82b..81ff46523f4d62cddc2fa5cf4ddf9718462587ed 100755 --- a/script/check_dnf_automatic +++ b/script/check_dnf_automatic @@ -10,23 +10,20 @@ # This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. # ======================================================================================================================================= - _version="0.5" _requirements=('dnf-automatic' 'tail' 'sed') - declare -A _exit_code _exit_code[OK]="0" _exit_code[WARNING]="1" _exit_code[CRITICAL]="2" _exit_code[UNKNOWN]="3" -print_help() -{ +print_help() { printf '%s\n' "This script checks the status of dnf-automatic." printf 'Usage: %s [--only-security] [--version] [-h|--help]\n' "$0" printf '\t%s\n' "--only-security: Do not issue a warning for non-security updates" @@ -34,32 +31,30 @@ print_help() printf '\t%s\n' "-h, --help: Print help (this text!)" } -parse_commandline() -{ - while test $# -gt 0 - do +parse_commandline() { + while test $# -gt 0; do _key="$1" case "$_key" in - --only-security) - _arg_only_security=1 - ;; - --version) - echo "$_version" - exit 0 - ;; - -h|--help) - print_help - exit 0 - ;; - -h*) - print_help - exit 0 - ;; - *) - print_help - echo "DNF UNKNOWN: Unexpected argument '$1'" - exit "${_exit_code[UNKNOWN]}" - ;; + --only-security) + _arg_only_security=1 + ;; + --version) + echo "$_version" + exit 0 + ;; + -h | --help) + print_help + exit 0 + ;; + -h*) + print_help + exit 0 + ;; + *) + print_help + echo "DNF UNKNOWN: Unexpected argument '$1'" + exit "${_exit_code[UNKNOWN]}" + ;; esac shift done diff --git a/tests/dnf-automatic-mock b/tests/dnf-automatic-mock index 512f244507f22b7b892a75c84bc3166f1bad076a..dadc34043bf92610f93616f6844cadab387c3ae5 100755 --- a/tests/dnf-automatic-mock +++ b/tests/dnf-automatic-mock @@ -6,16 +6,15 @@ # dnf-automatic-mock --updates-available # dnf-automatic-mock --no-updates - _output_type="$1" -_test_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) +_test_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd) if [[ "$_output_type" == "--updates-needed" ]]; then - cat "$_test_dir/updates_needed.out" + cat "$_test_dir/updates_needed.out" elif [[ "$_output_type" == "--updates-available" ]]; then - cat "$_test_dir/updates_available.out" + cat "$_test_dir/updates_available.out" elif [[ "$_output_type" == "--no-updates" ]]; then - cat "$_test_dir/no_updates.out" + cat "$_test_dir/no_updates.out" else - echo "ERROR: Unknown or undefined output type" -fi \ No newline at end of file + echo "ERROR: Unknown or undefined output type" +fi