From 0967ec1a8e350310485088e185465cfc9f26faf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Tue, 9 Nov 2021 06:46:12 +0100 Subject: [PATCH] Added sudo/doas in the script Logs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .local/bin/Logs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.local/bin/Logs b/.local/bin/Logs index a4082ae..54b09ef 100755 --- a/.local/bin/Logs +++ b/.local/bin/Logs @@ -1,11 +1,19 @@ #!/bin/bash NUMBER="-1" +if command -v sudo; then + sudo=$(which sudo) +elif command -v doas; then + sudo=$(which doas) +else + echo "Do you have installed sudo or doas on your system??" +fi + while true do clear - LOGS=( $(sudo find /var/tmp/portage/ -mindepth 1 -maxdepth 5 -name "build.log") $(sudo find /var/tmpnotmpfs/portage/ -mindepth 1 -maxdepth 5 -name "build.log") ) + LOGS=( $(${sudo} find /var/tmp/portage/ -mindepth 1 -maxdepth 5 -name "build.log") $(${sudo} find /var/tmpnotmpfs/portage/ -mindepth 1 -maxdepth 5 -name "build.log") ) LEN=${#LOGS[@]} for (( i=0; i<$LEN; i++ )); @@ -20,4 +28,4 @@ do done echo -e "\n\e[93m File: ${LOGS[$NUMBER-1]} \e[0m\n" -sudo tail -f ${LOGS[$NUMBER-1]} +${sudo} tail -f "${LOGS[$NUMBER-1]}"