mise au point fonction commandIsWorking

This commit is contained in:
2021-07-02 11:54:44 +02:00
parent 83aa4dc018
commit e8f10d4e42

View File

@@ -68,8 +68,8 @@ fi
#Ok if dir exists #Ok if dir exists
# arg1: dir to check # arg1: dir to check
function dirMustExists { function dirMustExists {
if [ -d ${1} ] ; then echo -ne "1;" if [ -d ${1} ] ; then e 1
else echo -ne "0;" else e 0
fi fi
} }
# Ok if given dir DOESNOT exists # Ok if given dir DOESNOT exists
@@ -219,10 +219,16 @@ function processIsRunning {
} }
#Ok if given command returns 0 #Ok if given command returns 0
# arg1: command to be run # arg1: chroot dir
# arg2: command to be run
function commandIsWorking { function commandIsWorking {
command=$1 chroot=$1
if ( $command &> /dev/null ) ; then echo -ne "1;" ; else echo -ne "0;" ; fi 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 # ok if given pattern is detected on command's stdout or stderr