cli: fix liner not closing (spuriously opened) in noninteractive jsre

This commit is contained in:
zelig 2015-03-24 14:09:06 +00:00
parent fd8d18ec28
commit 1c4c71dcff
2 changed files with 4 additions and 4 deletions

View File

@ -67,14 +67,14 @@ type jsre struct {
prompter prompter
} }
func newJSRE(ethereum *eth.Ethereum, libPath string) *jsre { func newJSRE(ethereum *eth.Ethereum, libPath string, interactive bool) *jsre {
js := &jsre{ethereum: ethereum, ps1: "> "} js := &jsre{ethereum: ethereum, ps1: "> "}
js.xeth = xeth.New(ethereum, js) js.xeth = xeth.New(ethereum, js)
js.re = re.New(libPath) js.re = re.New(libPath)
js.apiBindings() js.apiBindings()
js.adminBindings() js.adminBindings()
if !liner.TerminalSupported() { if !liner.TerminalSupported() || !interactive {
js.prompter = dumbterm{bufio.NewReader(os.Stdin)} js.prompter = dumbterm{bufio.NewReader(os.Stdin)}
} else { } else {
lr := liner.NewLiner() lr := liner.NewLiner()

View File

@ -246,7 +246,7 @@ func console(ctx *cli.Context) {
} }
startEth(ctx, ethereum) startEth(ctx, ethereum)
repl := newJSRE(ethereum, ctx.String(utils.JSpathFlag.Name)) repl := newJSRE(ethereum, ctx.String(utils.JSpathFlag.Name), true)
repl.interactive() repl.interactive()
ethereum.Stop() ethereum.Stop()
@ -261,7 +261,7 @@ func execJSFiles(ctx *cli.Context) {
} }
startEth(ctx, ethereum) startEth(ctx, ethereum)
repl := newJSRE(ethereum, ctx.String(utils.JSpathFlag.Name)) repl := newJSRE(ethereum, ctx.String(utils.JSpathFlag.Name), false)
for _, file := range ctx.Args() { for _, file := range ctx.Args() {
repl.exec(file) repl.exec(file)
} }