From 62bcb5a71d062f6296b016046ada195544880972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20S?= Date: Tue, 19 Feb 2019 10:43:51 +0100 Subject: [PATCH] Fixes #54 by refactoring IS_LISTCHANGESCONF Verbose mode previously added was misbehaving. Also refactored the code for more readability. --- evocheck.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/evocheck.sh b/evocheck.sh index ef728bc..0c02569 100755 --- a/evocheck.sh +++ b/evocheck.sh @@ -266,11 +266,21 @@ if [ -e /etc/debian_version ]; then if [ "$IS_LISTCHANGESCONF" = 1 ]; then if is_debianversion stretch; then - is_installed apt-listchanges && echo 'IS_LISTCHANGESCONF FAILED!' \ - && verbose "apt-listchanges must not be installed on Stretch" + if is_installed apt-listchanges; then + echo 'IS_LISTCHANGESCONF FAILED!' + verbose "apt-listchanges must not be installed on Stretch" + fi else - test -e /etc/apt/listchanges.conf && grep -E "(which=both|confirm=1)" /etc/apt/listchanges.conf | wc -l | grep -q ^2$ || echo 'IS_LISTCHANGESCONF FAILED!' \ - && verbose "apt-listchanges config is incorrect" + if [ -e "/etc/apt/listchanges.conf" ]; then + lines=$(grep -cE "(which=both|confirm=1)" /etc/apt/listchanges.conf) + if [ $lines != 2 ]; then + echo 'IS_LISTCHANGESCONF FAILED!' + verbose "apt-listchanges config is incorrect" + fi + else + echo 'IS_LISTCHANGESCONF FAILED!' + verbose "apt-listchanges config is missing" + fi fi fi