Fix regexp parsing whilst SMART test in progress

This commit is contained in:
prpr 2023-11-22 15:58:13 +00:00
parent e1b038d161
commit 114550d540

View File

@ -194,18 +194,14 @@ puts {
if {[catch {exec /bin/smartctl -l selftest $device} msg]} { if {[catch {exec /bin/smartctl -l selftest $device} msg]} {
set rc [lindex $::errorCode 2] set rc [lindex $::errorCode 2]
set rc $($rc eq "" ? 1 : [expr {$rc & 7}]) set rc $($rc eq "" ? 1 : [expr {$rc & 7}])
if {$rc} { if {$rc} { set msg "" }
set msg ""
}
} }
set i 0 set i 0
foreach line [split $msg "\n"] { foreach line [split $msg "\n"] {
regsub -all -- {[[:space:]][[:space:]]+} $line "|" line
if {[incr i] < 7} continue if {[incr i] < 7} continue
lassign [split $line "|"] id name status remaining when lba if {[regexp {\s*#\s*(\d+)\s+((?:[\s-]?\w[:;.,]?)+)\s+((?:[\s-]?\w[:;.,]?)+?)\s+(\d\d?%)\s+(\d+)\s+([\d-]\d*)} \
if {[string length $id] > 10} continue $line x id name status remaining when lba] == 0} continue
if {$id eq ""} continue
puts "<tr> puts "<tr>
<td>$id</td> <td>$id</td>
<td>$name</td> <td>$name</td>