mftest: Fix multi-line commands

This commit is contained in:
Scott Lahteine 2019-07-14 11:36:44 -05:00 committed by Scott Lahteine
parent 74e1573b14
commit 39a5e3ca6e

View File

@ -35,6 +35,7 @@ esac
ISNUM='^[0-9]+$' ISNUM='^[0-9]+$'
ISCMD='^(restore|opt|exec|use|pins|env)_' ISCMD='^(restore|opt|exec|use|pins|env)_'
ISEXEC='^exec_' ISEXEC='^exec_'
ISCONT='\\ *$'
# List available tests and ask for selection # List available tests and ask for selection
if [[ $TESTENV == '-' ]]; then if [[ $TESTENV == '-' ]]; then
@ -102,9 +103,11 @@ fi
# Finally, run the specified test lines # Finally, run the specified test lines
echo "$OUT" | { echo "$OUT" | {
IND=0 IND=0
GOTX=0
CMD=""
while IFS= read -r LINE while IFS= read -r LINE
do do
if [[ $LINE =~ $ISCMD ]]; then if [[ $LINE =~ $ISCMD || $GOTX == 1 ]]; then
((!IND)) && let IND++ ((!IND)) && let IND++
if [[ $LINE =~ $ISEXEC ]]; then if [[ $LINE =~ $ISEXEC ]]; then
((IND++ > CHOICE)) && break ((IND++ > CHOICE)) && break
@ -113,7 +116,11 @@ echo "$OUT" | {
HEADER=1 HEADER=1
echo -e "\n#\n# Test $TESTENV ($CHOICE) $DESC\n#" echo -e "\n#\n# Test $TESTENV ($CHOICE) $DESC\n#"
} }
((IND == CHOICE)) && { echo "$LINE" ; eval "$LINE" ; } ((IND == CHOICE)) && {
GOTX=1
[[ $CMD == "" ]] && CMD="$LINE" || CMD=$( echo -e "$CMD$LINE" | sed -e 's/\\//g' )
[[ $LINE =~ $ISCONT ]] || { echo $CMD ; eval "$CMD" ; CMD="" ; }
}
fi fi
fi fi
done done