Skip to content

Commit 3dd8295

Browse files
author
Michael Jennings
committed
Additional (final?) tweaks to check_cmd_output() for wrapping.
1 parent 123e4ae commit 3dd8295

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

scripts/lbnl_cmd.nhc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function check_cmd_output() {
1414

1515
MATCHES=( )
1616
OPTIND=1
17-
while getopts ":C:O:e:m:r:t:" OPTION ; do
17+
while getopts ":C:M:O:e:m:r:t:" OPTION ; do
1818
case "$OPTION" in
1919
C) CHECKNAME="$OPTARG" ;; # Used for writing wrapper checks
2020
O) OUTPUT_VAR="$OPTARG" ;; # Used for writing wrapper checks
@@ -78,7 +78,7 @@ function check_cmd_output() {
7878
if [[ "${MATCHES[$i]:0:1}" = '!' ]]; then
7979
# Match expression is negated. Fail if the line matches this expression.
8080
if mcheck "${LINES[$LINENO]}" "${MATCHES[$i]:1}" ; then
81-
MSG=${MSGS[$i]:-\"%m\" matched at line %l output by \"%c\"}
81+
MSG=${MSGS[$i]:-\"%m\" matched at line %l of \"%c\"}
8282
MSG=${MSG//\%m/${MATCHES[$i]:1}}
8383
MSG=${MSG//\%l/$((LINENO+1))}
8484
MSG=${MSG//\%c/$CMD}
@@ -127,10 +127,11 @@ function check_cmd_output() {
127127

128128
for ((i = 0; i < ${#MATCHES[*]}; i++)); do
129129
if [[ ${MATCHED[$i]} == 0 ]]; then
130-
MSG=${MSGS[$i]:-\"%m\" failed to match \"%c\" output}
130+
MSG=${MSGS[$i]:-\"%m\" failed to match \"%c\" output (%f patterns failed)}
131131
MSG=${MSG//\%m/${MATCHES[0]}}
132132
MSG=${MSG//\%c/$CMD}
133-
die 1 "$CHECKNAME: $MSG ($((${#MATCHES[*]}-MATCH_CNT))/${#MATCHES[*]} patterns failed)."
133+
MSG=${MSG//\%f/$((${#MATCHES[*]}-MATCH_CNT))/${#MATCHES[*]}}
134+
die 1 "$CHECKNAME: $MSG."
134135
return 1
135136
fi
136137
done

0 commit comments

Comments
 (0)