From e8f10d4e426f23fb337fb30c954cd7dc73961724 Mon Sep 17 00:00:00 2001 From: ThomasC Date: Fri, 2 Jul 2021 11:54:44 +0200 Subject: [PATCH] mise au point fonction commandIsWorking --- functions.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/functions.sh b/functions.sh index 2ff540e..a790d5b 100644 --- a/functions.sh +++ b/functions.sh @@ -68,8 +68,8 @@ fi #Ok if dir exists # arg1: dir to check function dirMustExists { -if [ -d ${1} ] ; then echo -ne "1;" - else echo -ne "0;" +if [ -d ${1} ] ; then e 1 + else e 0 fi } # Ok if given dir DOESNOT exists @@ -219,10 +219,16 @@ function processIsRunning { } #Ok if given command returns 0 -# arg1: command to be run +# arg1: chroot dir +# arg2: command to be run function commandIsWorking { - command=$1 - if ( $command &> /dev/null ) ; then echo -ne "1;" ; else echo -ne "0;" ; fi + chroot=$1 + shift + command="$@" + chroot ${chroot} bash -c "$command" &> /dev/null + ret=$? + if [ $ret -eq 0 ] ; then e 1 ; else e 0 ; fi + } # ok if given pattern is detected on command's stdout or stderr