mise au point command stdout

This commit is contained in:
2021-07-23 23:13:47 +02:00
parent e74ada7369
commit e512af4a41

View File

@@ -232,13 +232,16 @@ function commandIsWorking {
} }
# ok if given pattern is detected on command's stdout or stderr # ok if given pattern is detected on command's stdout or stderr
# arg1: command # arg1: chroot
# arg2: pattern # arg2: command
# arg3: pattern
function commandStdoutPattern { function commandStdoutPattern {
command=$1 chroot=$1
command=$2
shift shift
pattern=$@ pattern=$@
if ( $command 2>&1 | grep -qiE "${pattern}" ) ; then echo -ne "1;" ; else echo -ne "0;" ; fi result=$(chroot ${chroot} bash -c "$command")
if ( echo -n "$result" | grep -qiE "${pattern}" ) ; then echo -ne "1;" ; else echo -ne "0;" ; fi
} }
# ok if given service is enabled # ok if given service is enabled