fix: handle missing histfile correctly

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

View file

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