forked from hummypkg/webif
1
0
Fork 0

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
1 changed files with 3 additions and 7 deletions

View File

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