Merge pull request #427 from zseha/master

^D interrupt does the same as ^C
This commit is contained in:
evilsocket 2019-01-31 10:17:25 +01:00 committed by GitHub
commit 08a5ebb328
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 9 deletions

18
main.go
View file

@ -93,14 +93,8 @@ func main() {
for sess.Active {
line, err := sess.ReadLine()
if err != nil {
if err == io.EOF {
continue
} 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" {
if err == io.EOF || err.Error() == "Interrupt" {
if exitPrompt() {
sess.Run("exit")
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"
}

View file

@ -74,7 +74,7 @@ func (s *Session) setupReadline() (err error) {
cfg := readline.Config{
HistoryFile: history,
InterruptPrompt: "^C",
EOFPrompt: "exit",
EOFPrompt: "^D",
AutoComplete: readline.NewPrefixCompleter(prefixCompleters...),
}