File tree Expand file tree Collapse file tree 1 file changed +17
-8
lines changed
lib/msf/ui/console/command_dispatcher Expand file tree Collapse file tree 1 file changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -479,28 +479,37 @@ def cmd_exit(*args)
479
479
alias cmd_quit cmd_exit
480
480
481
481
def cmd_history ( *args )
482
- return cmd_history_help if args . length == 0
483
-
484
- limit = @history_limit
485
482
length = Readline ::HISTORY . length
486
483
487
- @@history_opts . parse ( args ) do |opt , _idx , val |
484
+ if length < @history_limit
485
+ limit = length
486
+ else
487
+ limit = @history_limit
488
+ end
489
+
490
+ @@history_opts . parse ( args ) do |opt , idx , val |
488
491
case opt
489
492
when "-a"
490
493
limit = length
491
494
when "-n"
492
495
return cmd_history_help unless val && val . match ( /\A [-+]?\d +\z / )
493
- limit = val . to_i
494
- limit = length if limit >= length
496
+ if length < val . to_i
497
+ limit = length
498
+ else
499
+ limit = val . to_i
500
+ end
495
501
when "-h"
496
502
cmd_history_help
497
503
return false
498
504
end
499
505
end
500
506
501
- start = length - limit
507
+ start = length - limit
508
+ pad_len = length . to_s . length
509
+
502
510
( start ..length -1 ) . each do |pos |
503
- print "#{ pos + 1 } #{ Readline ::HISTORY [ pos ] } \n "
511
+ cmd_num = ( pos + 1 ) . to_s
512
+ print_line "#{ cmd_num . ljust ( pad_len ) } #{ Readline ::HISTORY [ pos ] } "
504
513
end
505
514
end
506
515
You can’t perform that action at this time.
0 commit comments