mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 13:09:49 -07:00
Merge pull request #427 from zseha/master
^D interrupt does the same as ^C
This commit is contained in:
commit
08a5ebb328
2 changed files with 11 additions and 9 deletions
18
main.go
18
main.go
|
@ -93,14 +93,8 @@ func main() {
|
||||||
for sess.Active {
|
for sess.Active {
|
||||||
line, err := sess.ReadLine()
|
line, err := sess.ReadLine()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == io.EOF {
|
if err == io.EOF || err.Error() == "Interrupt" {
|
||||||
continue
|
if exitPrompt() {
|
||||||
} else if err.Error() == "Interrupt" {
|
|
||||||
var ans string
|
|
||||||
fmt.Printf("Are you sure you want to quit this session? y/n ")
|
|
||||||
fmt.Scan(&ans)
|
|
||||||
|
|
||||||
if strings.ToLower(ans) == "y" {
|
|
||||||
sess.Run("exit")
|
sess.Run("exit")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
@ -117,3 +111,11 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func exitPrompt() bool {
|
||||||
|
var ans string
|
||||||
|
fmt.Printf("Are you sure you want to quit this session? y/n ")
|
||||||
|
fmt.Scan(&ans)
|
||||||
|
|
||||||
|
return strings.ToLower(ans) == "y"
|
||||||
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ func (s *Session) setupReadline() (err error) {
|
||||||
cfg := readline.Config{
|
cfg := readline.Config{
|
||||||
HistoryFile: history,
|
HistoryFile: history,
|
||||||
InterruptPrompt: "^C",
|
InterruptPrompt: "^C",
|
||||||
EOFPrompt: "exit",
|
EOFPrompt: "^D",
|
||||||
AutoComplete: readline.NewPrefixCompleter(prefixCompleters...),
|
AutoComplete: readline.NewPrefixCompleter(prefixCompleters...),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue