Skip to content

Commit adc1b50

Browse files
committed
Merge pull request bnb-chain#2567 from fjl/console-history-exclude
cmd/geth: fix console history exclusion
2 parents fe532a9 + 86da6fe commit adc1b50

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

‎cmd/geth/js.go‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import (
4242

4343
var (
4444
passwordRegexp = regexp.MustCompile("personal.[nu]")
45-
leadingSpace = regexp.MustCompile("^ ")
4645
onlyws = regexp.MustCompile("^\\s*$")
4746
exit = regexp.MustCompile("^\\s*exit\\s*;*\\s*$")
4847
)
@@ -361,7 +360,7 @@ func (self *jsre) interactive() {
361360
str += input + "\n"
362361
self.setIndent()
363362
if indentCount <= 0 {
364-
if mustLogInHistory(str) {
363+
if !excludeFromHistory(str) {
365364
utils.Stdin.AppendHistory(str[:len(str)-1])
366365
}
367366
self.parseInput(str)
@@ -371,10 +370,8 @@ func (self *jsre) interactive() {
371370
}
372371
}
373372

374-
func mustLogInHistory(input string) bool {
375-
return len(input) == 0 ||
376-
passwordRegexp.MatchString(input) ||
377-
!leadingSpace.MatchString(input)
373+
func excludeFromHistory(input string) bool {
374+
return len(input) == 0 || input[0] == ' ' || passwordRegexp.MatchString(input)
378375
}
379376

380377
func (self *jsre) withHistory(datadir string, op func(*os.File)) {

0 commit comments

Comments
 (0)