From c501f9dd4eb8accab2bcf16472b27b997ad8d4b8 Mon Sep 17 00:00:00 2001 From: runner Date: Mon, 1 Aug 2016 13:29:49 +0800 Subject: [PATCH] fix #6070 fix #6070 on windows --- cmd/influx/cli/cli.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/cmd/influx/cli/cli.go b/cmd/influx/cli/cli.go index 409fb32998b..79bb7fa3f03 100644 --- a/cmd/influx/cli/cli.go +++ b/cmd/influx/cli/cli.go @@ -168,15 +168,20 @@ func (c *CommandLine) Run() error { c.Version() // Only load/write history if HOME environment variable is set. - if homeDir := os.Getenv("HOME"); homeDir != "" { - // Attempt to load the history file. - c.historyFilePath = filepath.Join(homeDir, ".influx_history") - if historyFile, err := os.Open(c.historyFilePath); err == nil { - c.Line.ReadHistory(historyFile) - historyFile.Close() + homeDir := os.Getenv("HOME") + if homeDir == "" { + if homeDir = os.Getenv("HOMEPATH"); homeDir == "" { + homeDir = "~" } } + // Attempt to load the history file. + c.historyFilePath = filepath.Join(homeDir, ".influx_history") + if historyFile, err := os.Open(c.historyFilePath); err == nil { + c.Line.ReadHistory(historyFile) + historyFile.Close() + } + // read from prompt until exit is run return c.mainLoop() }