@@ -88,7 +88,7 @@ class Core
88
88
@@history_opts = Rex ::Parser ::Arguments . new (
89
89
"-h" => [ false , "Help banner." ] ,
90
90
"-a" => [ false , "Show all commands in history." ] ,
91
- "-n" => [ true , "Show the last n commands." ] )
91
+ "-n" => [ true , "Show the last n commands." ] )
92
92
93
93
@@irb_opts = Rex ::Parser ::Arguments . new (
94
94
"-h" => [ false , "Help banner." ] ,
@@ -108,7 +108,7 @@ def commands
108
108
"getg" => "Gets the value of a global variable" ,
109
109
"grep" => "Grep the output of another command" ,
110
110
"help" => "Help menu" ,
111
- "history" => "Show commands history" ,
111
+ "history" => "Show command history" ,
112
112
"irb" => "Drop into irb scripting mode" ,
113
113
"load" => "Load a framework plugin" ,
114
114
"quit" => "Exit the console" ,
@@ -478,18 +478,18 @@ def cmd_exit(*args)
478
478
479
479
alias cmd_quit cmd_exit
480
480
481
-
482
481
def cmd_history ( *args )
483
-
482
+ return cmd_history_help if args . length == 0
483
+
484
484
limit = @history_limit
485
- length = Readline ::HISTORY . length
485
+ length = Readline ::HISTORY . length
486
486
487
487
@@history_opts . parse ( args ) do |opt , _idx , val |
488
488
case opt
489
489
when "-a"
490
490
limit = length
491
491
when "-n"
492
- return cmd_history_help unless ! val . nil? && val . match ( /\A [-+]?\d +\z / )
492
+ return cmd_history_help unless val && val . match ( /\A [-+]?\d +\z / )
493
493
limit = val . to_i
494
494
limit = length if limit >= length
495
495
when "-h"
@@ -498,23 +498,21 @@ def cmd_history(*args)
498
498
end
499
499
end
500
500
501
- start = length - limit
501
+ start = length - limit
502
502
( start ..length -1 ) . each do |pos |
503
- print "#{ pos } #{ Readline ::HISTORY [ pos ] } \n "
503
+ print "#{ pos + 1 } #{ Readline ::HISTORY [ pos ] } \n "
504
504
end
505
505
end
506
506
507
507
def cmd_history_help
508
508
print_line "Usage: history [options]"
509
509
print_line
510
510
print_line "Shows the command history."
511
- print_line "If -n is not set, it will only be shown the last #{ @history_limit } commands."
511
+ print_line "If -n is not set, only the last #{ @history_limit } commands will be shown ."
512
512
print_line
513
513
print @@history_opts . usage
514
514
end
515
515
516
-
517
-
518
516
def cmd_sleep_help
519
517
print_line "Usage: sleep <seconds>"
520
518
print_line
0 commit comments