do not crash with corrupted history entries

Related #455
This commit is contained in:
Gokcehan 2020-09-01 23:57:40 +03:00
parent bc0000f274
commit 658af50006

6
app.go
View File

@ -95,6 +95,12 @@ func (app *app) readHistory() error {
scanner := bufio.NewScanner(f) scanner := bufio.NewScanner(f)
for scanner.Scan() { for scanner.Scan() {
toks := strings.SplitN(scanner.Text(), " ", 2) toks := strings.SplitN(scanner.Text(), " ", 2)
if toks[0] != ":" && toks[0] != "$" && toks[0] != "%" && toks[0] != "!" && toks[0] != "&" {
continue
}
if len(toks) < 2 {
continue
}
app.cmdHistory = append(app.cmdHistory, cmdItem{toks[0], toks[1]}) app.cmdHistory = append(app.cmdHistory, cmdItem{toks[0], toks[1]})
} }