sscargal / pmemchk

MIT License
0 stars 1 forks source link

[Rules] Rules should return a SKIPPED status and message when no data is found in the input file(s) #146

Open sscargal opened 2 years ago

sscargal commented 2 years ago

Many rules use a simple WHILE..DONE loop to read the input file. If the test (grep|tail) doesn't return any data, the function returns, but does not set a result or message to the user. It would be useful to call rule_result SKIPPED "<message>" to inform the user why this rule was skipped.

  while IFS='|' read -r DimmID Property Value
  do
   <action>
  done <<<  "$(${GREP} ARSStatus  ${FNAME})" || return 0

Could be:

  while IFS='|' read -r DimmID Property Value
  do
   <action>
  done <<<  "$(${GREP} ARSStatus  ${FNAME})" || { rule_result SKIPPED "'ARSStatus': No such property found in ${FNAME}."; return 0; }