From 670e749451e77550c7c58dc4f3df5b911ed07e01 Mon Sep 17 00:00:00 2001 From: ThomasC Date: Wed, 2 Nov 2022 22:00:03 +0100 Subject: [PATCH] function commandOutput --- functions.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/functions.sh b/functions.sh index c64c299..d3ca1ef 100755 --- a/functions.sh +++ b/functions.sh @@ -276,6 +276,18 @@ function commandIsWorking { } +# return latest line of commande output +# arg1: chroot dir +# arg2: command to be run +function commandOutput { + chroot=$1 + shift + command="$@" + result=$(chroot ${chroot} bash -c "$command" 2> /dev/null) + ret=$? + if [ $ret -eq 0 ] ; then e ${result:=0} ; else e 0 ; fi + } + # get num of files in given dir # arg1: dir function numFilesInDir {