From cef3e2dc5a563fccb4c54b7bea2fddc071bf9541 Mon Sep 17 00:00:00 2001 From: rene <41963722+renaynay@users.noreply.github.com> Date: Tue, 20 Oct 2020 10:56:51 +0200 Subject: [PATCH] console: don't exit on ctrl-c, only on ctrl-d (#21660) * add interrupt counter * remove interrupt counter, allow ctrl-C to clear ONLY, ctrl-D will terminate console, stop node * format * add instructions to exit * fix tests --- cmd/geth/consolecmd_test.go | 2 ++ console/console.go | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/geth/consolecmd_test.go b/cmd/geth/consolecmd_test.go index 6c100e18d9..913b060361 100644 --- a/cmd/geth/consolecmd_test.go +++ b/cmd/geth/consolecmd_test.go @@ -66,6 +66,7 @@ at block: 0 ({{niltime}}) datadir: {{.Datadir}} modules: {{apis}} +To exit, press ctrl-d > {{.InputLine "exit"}} `) geth.ExpectExit() @@ -159,6 +160,7 @@ at block: 0 ({{niltime}}){{if ipc}} datadir: {{datadir}}{{end}} modules: {{apis}} +To exit, press ctrl-d > {{.InputLine "exit" }} `) attach.ExpectExit() diff --git a/console/console.go b/console/console.go index 1dcad3065e..ae9f28da04 100644 --- a/console/console.go +++ b/console/console.go @@ -324,6 +324,7 @@ func (c *Console) Welcome() { sort.Strings(modules) message += " modules: " + strings.Join(modules, " ") + "\n" } + message += "\nTo exit, press ctrl-d" fmt.Fprintln(c.printer, message) } @@ -372,7 +373,7 @@ func (c *Console) Interactive() { return case err := <-inputErr: - if err == liner.ErrPromptAborted && indents > 0 { + if err == liner.ErrPromptAborted { // When prompting for multi-line input, the first Ctrl-C resets // the multi-line state. prompt, indents, input = c.prompt, 0, ""