mirror of https://github.com/bcicen/ctop.git
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
|
package single
|
||||||
|
|
||||||
import (
|
import (
|
||||||
ui "github.com/gizak/termui"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
ui "github.com/gizak/termui"
|
||||||
)
|
)
|
||||||
|
|
||||||
var envPattern = regexp.MustCompile(`(?P<KEY>[^=]+)=(?P<VALUJE>.*)`)
|
var envPattern = regexp.MustCompile(`(?P<KEY>[^=]+)=(?P<VALUJE>.*)`)
|
||||||
|
@ -29,10 +30,12 @@ func (w *Env) Set(allEnvs string) {
|
||||||
w.Rows = [][]string{}
|
w.Rows = [][]string{}
|
||||||
for _, env := range envs {
|
for _, env := range envs {
|
||||||
match := envPattern.FindStringSubmatch(env)
|
match := envPattern.FindStringSubmatch(env)
|
||||||
key := match[1]
|
if len(match) == 3 {
|
||||||
value := match[2]
|
key := match[1]
|
||||||
w.data[key] = value
|
value := match[2]
|
||||||
w.Rows = append(w.Rows, mkInfoRows(key, value)...)
|
w.data[key] = value
|
||||||
|
w.Rows = append(w.Rows, mkInfoRows(key, value)...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Height = len(w.Rows) + 2
|
w.Height = len(w.Rows) + 2
|
||||||
|
|
Loading…
Reference in New Issue