Fix readline history
This commit is contained in:
parent
c4f90625f6
commit
c158939998
@ -63,10 +63,12 @@ func Run(run bool, pid int, args []string) {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
cmds := command.DebugCommands()
|
cmds := command.DebugCommands()
|
||||||
if f, err := os.Open(historyFile); err == nil {
|
f, err := os.Open(historyFile)
|
||||||
line.ReadHistory(f)
|
if err != nil {
|
||||||
f.Close()
|
f, _ = os.Create(historyFile)
|
||||||
}
|
}
|
||||||
|
line.ReadHistory(f)
|
||||||
|
f.Close()
|
||||||
fmt.Println("Type 'help' for list of commands.")
|
fmt.Println("Type 'help' for list of commands.")
|
||||||
|
|
||||||
for {
|
for {
|
||||||
@ -93,8 +95,11 @@ func Run(run bool, pid int, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func handleExit(dbp *proctl.DebuggedProcess, line *liner.State, status int) {
|
func handleExit(dbp *proctl.DebuggedProcess, line *liner.State, status int) {
|
||||||
if f, err := os.Open(historyFile); err == nil {
|
if f, err := os.OpenFile(historyFile, os.O_RDWR, 0666); err == nil {
|
||||||
line.WriteHistory(f)
|
_, err := line.WriteHistory(f)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("readline histroy: ", err)
|
||||||
|
}
|
||||||
f.Close()
|
f.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user