mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
prevent index out of range panic on empty value env strings
This commit is contained in:
parent
021b1710a3
commit
acbf17a4fd
@ -1,9 +1,10 @@
|
||||
package single
|
||||
|
||||
import (
|
||||
ui "github.com/gizak/termui"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
ui "github.com/gizak/termui"
|
||||
)
|
||||
|
||||
var envPattern = regexp.MustCompile(`(?P<KEY>[^=]+)=(?P<VALUJE>.*)`)
|
||||
@ -29,10 +30,12 @@ func (w *Env) Set(allEnvs string) {
|
||||
w.Rows = [][]string{}
|
||||
for _, env := range envs {
|
||||
match := envPattern.FindStringSubmatch(env)
|
||||
key := match[1]
|
||||
value := match[2]
|
||||
w.data[key] = value
|
||||
w.Rows = append(w.Rows, mkInfoRows(key, value)...)
|
||||
if len(match) == 3 {
|
||||
key := match[1]
|
||||
value := match[2]
|
||||
w.data[key] = value
|
||||
w.Rows = append(w.Rows, mkInfoRows(key, value)...)
|
||||
}
|
||||
}
|
||||
|
||||
w.Height = len(w.Rows) + 2
|
||||
|
Loading…
Reference in New Issue
Block a user