Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
e13f413e
Commit
e13f413e
authored
May 27, 2015
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1112 from fjl/fix-console-exit
cmd/geth: exit the console cleanly when interrupted
parents
69f7a1da
9253fc33
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
20 deletions
+44
-20
js.go
cmd/geth/js.go
+44
-20
No files found.
cmd/geth/js.go
View file @
e13f413e
...
...
@@ -22,6 +22,7 @@ import (
"fmt"
"math/big"
"os"
"os/signal"
"path/filepath"
"strings"
...
...
@@ -47,7 +48,8 @@ type dumbterm struct{ r *bufio.Reader }
func
(
r
dumbterm
)
Prompt
(
p
string
)
(
string
,
error
)
{
fmt
.
Print
(
p
)
return
r
.
r
.
ReadString
(
'\n'
)
line
,
err
:=
r
.
r
.
ReadString
(
'\n'
)
return
strings
.
TrimSuffix
(
line
,
"
\n
"
),
err
}
func
(
r
dumbterm
)
PasswordPrompt
(
p
string
)
(
string
,
error
)
{
...
...
@@ -182,30 +184,52 @@ func (self *jsre) exec(filename string) error {
}
func
(
self
*
jsre
)
interactive
()
{
for
{
input
,
err
:=
self
.
Prompt
(
self
.
ps1
)
if
err
!=
nil
{
break
// Read input lines.
prompt
:=
make
(
chan
string
)
inputln
:=
make
(
chan
string
)
go
func
()
{
defer
close
(
inputln
)
for
{
line
,
err
:=
self
.
Prompt
(
<-
prompt
)
if
err
!=
nil
{
return
}
inputln
<-
line
}
if
input
==
""
{
continue
}()
// Wait for Ctrl-C, too.
sig
:=
make
(
chan
os
.
Signal
,
1
)
signal
.
Notify
(
sig
,
os
.
Interrupt
)
defer
func
()
{
if
self
.
atexit
!=
nil
{
self
.
atexit
()
}
str
+=
input
+
"
\n
"
self
.
setIndent
()
if
indentCount
<=
0
{
if
input
==
"exit"
{
break
self
.
re
.
Stop
(
false
)
}()
for
{
prompt
<-
self
.
ps1
select
{
case
<-
sig
:
fmt
.
Println
(
"caught interrupt, exiting"
)
return
case
input
,
ok
:=
<-
inputln
:
if
!
ok
||
indentCount
<=
0
&&
input
==
"exit"
{
return
}
if
input
==
""
{
continue
}
str
+=
input
+
"
\n
"
self
.
setIndent
()
if
indentCount
<=
0
{
hist
:=
str
[
:
len
(
str
)
-
1
]
self
.
AppendHistory
(
hist
)
self
.
parseInput
(
str
)
str
=
""
}
hist
:=
str
[
:
len
(
str
)
-
1
]
self
.
AppendHistory
(
hist
)
self
.
parseInput
(
str
)
str
=
""
}
}
if
self
.
atexit
!=
nil
{
self
.
atexit
()
}
self
.
re
.
Stop
(
false
)
}
func
(
self
*
jsre
)
withHistory
(
op
func
(
*
os
.
File
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment