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
This commit is contained in:
rene 2020-10-20 10:56:51 +02:00 committed by GitHub
parent b305591e14
commit cef3e2dc5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

@ -66,6 +66,7 @@ at block: 0 ({{niltime}})
datadir: {{.Datadir}} datadir: {{.Datadir}}
modules: {{apis}} modules: {{apis}}
To exit, press ctrl-d
> {{.InputLine "exit"}} > {{.InputLine "exit"}}
`) `)
geth.ExpectExit() geth.ExpectExit()
@ -159,6 +160,7 @@ at block: 0 ({{niltime}}){{if ipc}}
datadir: {{datadir}}{{end}} datadir: {{datadir}}{{end}}
modules: {{apis}} modules: {{apis}}
To exit, press ctrl-d
> {{.InputLine "exit" }} > {{.InputLine "exit" }}
`) `)
attach.ExpectExit() attach.ExpectExit()

@ -324,6 +324,7 @@ func (c *Console) Welcome() {
sort.Strings(modules) sort.Strings(modules)
message += " modules: " + strings.Join(modules, " ") + "\n" message += " modules: " + strings.Join(modules, " ") + "\n"
} }
message += "\nTo exit, press ctrl-d"
fmt.Fprintln(c.printer, message) fmt.Fprintln(c.printer, message)
} }
@ -372,7 +373,7 @@ func (c *Console) Interactive() {
return return
case err := <-inputErr: case err := <-inputErr:
if err == liner.ErrPromptAborted && indents > 0 { if err == liner.ErrPromptAborted {
// When prompting for multi-line input, the first Ctrl-C resets // When prompting for multi-line input, the first Ctrl-C resets
// the multi-line state. // the multi-line state.
prompt, indents, input = c.prompt, 0, "" prompt, indents, input = c.prompt, 0, ""