From 50df2b78be038fceb6975582a5f07052de939cbc Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Tue, 19 Dec 2017 13:21:03 +0100 Subject: console: create datadir at startup (#15700) Fixes #15672 by creating the datadir when creating the console. This prevents failing to save the history if no datadir exists. --- console/console.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'console') diff --git a/console/console.go b/console/console.go index 1ecbfd0b0..52fe1f542 100644 --- a/console/console.go +++ b/console/console.go @@ -92,6 +92,9 @@ func New(config Config) (*Console, error) { printer: config.Printer, histPath: filepath.Join(config.DataDir, HistoryFile), } + if err := os.MkdirAll(config.DataDir, 0700); err != nil { + return nil, err + } if err := console.init(config.Preload); err != nil { return nil, err } @@ -423,7 +426,7 @@ func (c *Console) Execute(path string) error { return c.jsre.Exec(path) } -// Stop cleans up the console and terminates the runtime envorinment. +// Stop cleans up the console and terminates the runtime environment. func (c *Console) Stop(graceful bool) error { if err := ioutil.WriteFile(c.histPath, []byte(strings.Join(c.history, "\n")), 0600); err != nil { return err -- cgit v1.2.3 From 72e70bcec2e288e2f5d375290d194fd5832842e2 Mon Sep 17 00:00:00 2001 From: Richard Hart Date: Tue, 2 Jan 2018 07:00:13 -0500 Subject: console: remove comment about 'invalid' input (#15735) All inputs are saved into history, including 'invalid' inputs. --- console/prompter.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'console') diff --git a/console/prompter.go b/console/prompter.go index ea03694d4..c477b4817 100644 --- a/console/prompter.go +++ b/console/prompter.go @@ -155,8 +155,7 @@ func (p *terminalPrompter) SetHistory(history []string) { p.State.ReadHistory(strings.NewReader(strings.Join(history, "\n"))) } -// AppendHistory appends an entry to the scrollback history. It should be called -// if and only if the prompt to append was a valid command. +// AppendHistory appends an entry to the scrollback history. func (p *terminalPrompter) AppendHistory(command string) { p.State.AppendHistory(command) } -- cgit v1.2.3