Skip to content

Commit

Permalink
console: don't exit on ctrl-c, only on ctrl-d (#21660)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
renaynay authored Oct 20, 2020
1 parent b305591 commit cef3e2d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cmd/geth/consolecmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ at block: 0 ({{niltime}})
datadir: {{.Datadir}}
modules: {{apis}}
To exit, press ctrl-d
> {{.InputLine "exit"}}
`)
geth.ExpectExit()
Expand Down Expand Up @@ -159,6 +160,7 @@ at block: 0 ({{niltime}}){{if ipc}}
datadir: {{datadir}}{{end}}
modules: {{apis}}
To exit, press ctrl-d
> {{.InputLine "exit" }}
`)
attach.ExpectExit()
Expand Down
3 changes: 2 additions & 1 deletion console/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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, ""
Expand Down

0 comments on commit cef3e2d

Please sign in to comment.