diff --git a/functions.sh b/functions.sh index 396b49b..7ebd43a 100644 --- a/functions.sh +++ b/functions.sh @@ -232,13 +232,16 @@ function commandIsWorking { } # ok if given pattern is detected on command's stdout or stderr -# arg1: command -# arg2: pattern +# arg1: chroot +# arg2: command +# arg3: pattern function commandStdoutPattern { - command=$1 + chroot=$1 + command=$2 shift 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