Skip to content

Commit 645ed87

Browse files
committed
Fix GH #350
1 parent 0a45360 commit 645ed87

File tree

5 files changed

+502
-9
lines changed

5 files changed

+502
-9
lines changed

Changes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ The --not option can be used with either --and or --or.
66

77
The -g option can now use any of the boolean options, --and, --or or --not.
88

9+
[FIXES]
10+
When using --output='$f', the filename would be colorized in the output
11+
line, but should not have been. This has been fixed. Thanks, Dabrien
12+
'Dabe' Murphy. (GH #350)
13+
914

1015
v3.8.2 Sun Apr 6 10:45:04 CDT 2025
1116
========================================

MANIFEST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ t/ack-n.t
5959
t/ack-o.yaml
6060
t/ack-output.t
6161
t/ack-output.yaml
62+
t/ack-output-color.t
6263
t/ack-pager.t
6364
t/ack-passthru.t
6465
t/ack-print0.t

ack

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -904,20 +904,29 @@ sub print_line_with_options {
904904
my @line_parts;
905905

906906
if ( $opt_show_filename && defined($filename) ) {
907-
my $colno;
908-
$colno = get_match_colno() if $opt_column;
907+
my $disp_filename;
908+
my $disp_lineno;
909909
if ( $opt_color ) {
910-
$filename = Term::ANSIColor::colored( $filename, $ENV{ACK_COLOR_FILENAME} );
911-
$lineno = Term::ANSIColor::colored( $lineno, $ENV{ACK_COLOR_LINENO} );
912-
$colno = Term::ANSIColor::colored( $colno, $ENV{ACK_COLOR_COLNO} ) if $opt_column;
910+
$disp_filename = Term::ANSIColor::colored( $filename, $ENV{ACK_COLOR_FILENAME} );
911+
$disp_lineno = Term::ANSIColor::colored( $lineno, $ENV{ACK_COLOR_LINENO} );
913912
}
913+
else {
914+
$disp_filename = $filename;
915+
$disp_lineno = $lineno;
916+
}
917+
914918
if ( $opt_heading ) {
915-
push @line_parts, $lineno;
919+
push @line_parts, $disp_lineno;
916920
}
917921
else {
918-
push @line_parts, $filename, $lineno;
922+
push @line_parts, $disp_filename, $disp_lineno;
923+
}
924+
925+
if ( $opt_column ) {
926+
my $colno = get_match_colno();
927+
$colno = Term::ANSIColor::colored( $colno, $ENV{ACK_COLOR_COLNO} ) if $opt_color;
928+
push @line_parts, $colno;
919929
}
920-
push @line_parts, $colno if $opt_column;
921930
}
922931

923932
if ( $opt_output ) {

0 commit comments

Comments
 (0)