From 736c271d1814dc46655d13c73bec49fd866464b6 Mon Sep 17 00:00:00 2001 From: pvincent Date: Sun, 6 Feb 2022 13:01:39 +0400 Subject: [PATCH] verbose --- lib/functions.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/functions.sh b/lib/functions.sh index fe026d3..6a2d44f 100644 --- a/lib/functions.sh +++ b/lib/functions.sh @@ -1,10 +1,14 @@ +#!/bin/bash + # idempotent apt install [package1 package2 ...] function idem_apt_install() { - for i in $@; do + [ -z "${VERBOSE:-}" ] && VERBOSE=false + # || echo "VERBOSE is set to $VERBOSE" + for i in "$@"; do if ! (/usr/bin/dpkg-query --status "$i" >/dev/null 2>&1); then sudo apt install -y "$i" - else - $VERBOSE && echo "${PREFIX:=}apt package <$i> already installed!" + elif $VERBOSE; then + echo "${PREFIX:=}apt package <$i> already installed!" fi done }