1bf215546Sopenharmony_ci#!/bin/bash 2bf215546Sopenharmony_ci 3bf215546Sopenharmony_ciset -e 4bf215546Sopenharmony_ci 5bf215546Sopenharmony_ciSTRINGS=$(mktemp) 6bf215546Sopenharmony_ciERRORS=$(mktemp) 7bf215546Sopenharmony_ci 8bf215546Sopenharmony_citrap "rm $STRINGS; rm $ERRORS;" EXIT 9bf215546Sopenharmony_ci 10bf215546Sopenharmony_ciFILE=$1 11bf215546Sopenharmony_cishift 1 12bf215546Sopenharmony_ci 13bf215546Sopenharmony_ciwhile getopts "f:e:" opt; do 14bf215546Sopenharmony_ci case $opt in 15bf215546Sopenharmony_ci f) echo "$OPTARG" >> $STRINGS;; 16bf215546Sopenharmony_ci e) echo "$OPTARG" >> $STRINGS ; echo "$OPTARG" >> $ERRORS;; 17bf215546Sopenharmony_ci esac 18bf215546Sopenharmony_cidone 19bf215546Sopenharmony_cishift $((OPTIND -1)) 20bf215546Sopenharmony_ci 21bf215546Sopenharmony_ciecho "Waiting for $FILE to say one of following strings" 22bf215546Sopenharmony_cicat $STRINGS 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ciwhile ! egrep -wf $STRINGS $FILE; do 25bf215546Sopenharmony_ci sleep 2 26bf215546Sopenharmony_cidone 27bf215546Sopenharmony_ci 28bf215546Sopenharmony_ciif egrep -wf $ERRORS $FILE; then 29bf215546Sopenharmony_ci exit 1 30bf215546Sopenharmony_cifi 31