Skip to content

Commit 015b02f

Browse files
rjbstoddr
authored andcommitted
perl5db: allow the recorded history item length to be configured
This requires a few small changes. 1. add a new option, which I stored in what looked like one of the standard ways 2. only store the item in terminal history if >= this length 3. only add to @hist if >= this length 4. only display hist item if >= this length I believe #4 is redundant and should be removed, but the code was already effectively there.
1 parent 5eb398c commit 015b02f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/perl5db.pl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ =head3 The problem of lexicals
643643
$filename
644644
$histfile
645645
$histsize
646+
$histitemminlength
646647
$IN
647648
$inhibit_exit
648649
@ini_INC
@@ -938,6 +939,7 @@ =head1 OPTION PROCESSING
938939

939940
@options = qw(
940941
CommandSet HistFile HistSize
942+
HistItemMinLength
941943
hashDepth arrayDepth dumpDepth
942944
DumpDBFiles DumpPackages DumpReused
943945
compactDump veryCompact quote
@@ -986,6 +988,7 @@ =head1 OPTION PROCESSING
986988
windowSize => \$window,
987989
HistFile => \$histfile,
988990
HistSize => \$histsize,
991+
HistItemMinLength => \$histitemminlength
989992
);
990993

991994
=pod
@@ -2821,7 +2824,7 @@ =head4 The null command
28212824
$cmd = $laststep;
28222825
}
28232826
chomp($cmd); # get rid of the annoying extra newline
2824-
if (length($cmd) >= 2) {
2827+
if (length($cmd) >= option_val('HistItemMinLength', 2)) {
28252828
push( @hist, $cmd );
28262829
}
28272830
push( @truehist, $cmd );
@@ -3731,10 +3734,7 @@ sub _handle_H_command {
37313734
my $i;
37323735

37333736
for ( $i = $#hist ; $i > $end ; $i-- ) {
3734-
3735-
# Print the command unless it has no arguments.
3736-
print $OUT "$i: ", $hist[$i], "\n"
3737-
unless $hist[$i] =~ /^.?$/;
3737+
print $OUT "$i: ", $hist[$i], "\n";
37383738
}
37393739

37403740
next CMD;
@@ -7327,7 +7327,7 @@ sub readline {
73277327

73287328
# Add it to the terminal history (if possible).
73297329
$term->AddHistory($got)
7330-
if length($got) > 1
7330+
if length($got) >= option_val("HistItemMinLength", 2)
73317331
and defined $term->Features->{addHistory};
73327332
return $got;
73337333
} ## end if (@typeahead)

0 commit comments

Comments
 (0)