From c158939998893e6095551df8f829650baa3bbe67 Mon Sep 17 00:00:00 2001 From: Derek Parker Date: Sun, 1 Mar 2015 10:15:16 -0600 Subject: [PATCH] Fix readline history --- client/cli/cli.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/client/cli/cli.go b/client/cli/cli.go index bf421032..91a7c23f 100644 --- a/client/cli/cli.go +++ b/client/cli/cli.go @@ -63,10 +63,12 @@ func Run(run bool, pid int, args []string) { }() cmds := command.DebugCommands() - if f, err := os.Open(historyFile); err == nil { - line.ReadHistory(f) - f.Close() + f, err := os.Open(historyFile) + if err != nil { + f, _ = os.Create(historyFile) } + line.ReadHistory(f) + f.Close() fmt.Println("Type 'help' for list of commands.") for { @@ -93,8 +95,11 @@ func Run(run bool, pid int, args []string) { } func handleExit(dbp *proctl.DebuggedProcess, line *liner.State, status int) { - if f, err := os.Open(historyFile); err == nil { - line.WriteHistory(f) + if f, err := os.OpenFile(historyFile, os.O_RDWR, 0666); err == nil { + _, err := line.WriteHistory(f) + if err != nil { + fmt.Println("readline histroy: ", err) + } f.Close() }