beyondgrep / ack2

**ack 2 is no longer being maintained. ack 3 is the latest version.**
https://github.com/beyondgrep/ack3/
Other
1.48k stars 140 forks source link

$_ no longer available via --output #530

Closed hoelzro closed 5 years ago

hoelzro commented 9 years ago

Example:

$ ack-2.14 --output '@{chomp; [length() <= 50 ? $_ : "long string is long"]}' foo
dev/timings.pl
143:    [ 'foo', $SOURCE_DIR ],
144:long string is long
145:long string is long
...

$ ./ack-standalone --output '@{chomp; [length() <= 50 ? $_ : "long string is long"]}' foo
dev/timings.pl
Use of uninitialized value $_ in scalar chomp at (eval 144) line 1, <__ANONIO__> line 1.
Use of uninitialized value $_ in numeric le (<=) at (eval 144) line 1, <__ANONIO__> line 1.
Use of uninitialized value in join or string at (eval 144) line 1, <__ANONIO__> line 1.
143:
...

This is probably broken due to my optimization.

pdl commented 9 years ago

Perhaps I'm missing something, but the assumption that $_ means "the whole line" doesn't seem to be explained in the docs. Given that output has access to all variables in scope at that point in ack, it would be good to enumerate the variables for which users can expect ack to return a consistent value ($_[1] seems to return the filename, for instance; $. also works). The main regexp variables are documented, which is good, and presumably the more exotic ones are too, but support or otherwise of anything else is a design/maintainance decision.

hoelzro commented 9 years ago

I mentioned this in #531.

petdance commented 5 years ago

There will be no more releases of ack 2.