fix: handle missing histfile correctly
This commit is contained in:
parent
fa9a3657db
commit
59334482bb
1 changed files with 7 additions and 4 deletions
11
main.go
11
main.go
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue