Skip to content

Commit 5a3973b

Browse files
authored
ETT-407 Metadata Processing Verifier Misinterprets grep Exit Status (#71)
- Suppress spurious warning caused by `grep` exit status being 1. - Real `grep` errors are 2 and up, according to the man page. - Discontinue use of Process:Exitstatus#success? and do a numeric comparison.
1 parent 3887e4a commit 5a3973b

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

lib/verifier/post_zephir.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,17 @@ def verify_hathifile_contents(path:)
201201
# Records with all HTID rights set to e.g. supp/* do not get included in certain
202202
# downstream activities, e.g. hathifiles and catalog indexing.
203203
# Only applies to monthly files.
204+
GREP_ERR = 2
204205
def count_suppressed_records(derivative:)
205206
if derivative.full?
206207
if File.exist?(zephir_full_monthly_rpt_txt)
207208
cmd = "grep -c no.unsuppressed.*not.written #{zephir_full_monthly_rpt_txt}"
208209
stdout_str, stderr_str, status = Open3.capture3(cmd)
209-
if status.success?
210+
if status.exitstatus >= GREP_ERR
211+
error message: "count_suppressed_records: status #{status.exitstatus}, STDERR '#{stderr_str.chomp}' (#{cmd})"
212+
else
210213
# With the -c option we should reliably just get a number from STDOUT
211214
return stdout_str.chomp.to_i
212-
else
213-
error message: "count_suppressed_records: status #{status.exitstatus}, STDERR '#{stderr_str.chomp}' (#{cmd})"
214215
end
215216
end
216217
end

0 commit comments

Comments
 (0)