fix: handle missing histfile correctly

This commit is contained in:
yory8 2019-09-16 12:51:33 +02:00
parent fa9a3657db
commit 59334482bb

11
main.go
View file

@ -53,10 +53,13 @@ func main() {
var history []string var history []string
b, err := ioutil.ReadFile(histfile) b, err := ioutil.ReadFile(histfile)
if err != nil { if err != nil {
log.Fatalf("Failure reading history file: %s", err) if !os.IsNotExist(err) {
} log.Fatalf("Failure reading history file: %s", err)
if err := json.Unmarshal(b, &history); err != nil { }
log.Fatalf("Failure parsing history: %s", err) } else {
if err := json.Unmarshal(b, &history); err != nil {
log.Fatalf("Failure parsing history: %s", err)
}
} }
if *asDemon { if *asDemon {