Pager not being used in single-file ack 1.90

4 views
Skip to first unread message

Packy Anderson

unread,
Sep 18, 2009, 12:49:12 PM9/18/09
to ack-...@googlegroups.com
I'm having a minor problem with ack on our development server.  Since it's a machine shared by a bunch of developers, I'm not comfortable installing App::Ack for the whole machine, so I'm using the single-file 1.90 running out of my $HOME/bin.  Unfortunately, it's not using the pager.  I'll ack for some common string in my codebase, and the results scroll off the screen.  I could swear it was working before I upgraded to 1.90...

Some environment:

$ set | grep ^ACK
ACK_COLOR_FILENAME=red
ACK_OPTIONS='--type-add perl=.csv'
ACK_PAGER='less -FRX'
$ cat ~/.ackrc
--smart-case
--ignore-dir=build_agent_aix
--ignore-dir=build_agent_hpux
--ignore-dir=build_agent_linux
--ignore-dir=build_agent_solaris
--ignore-dir=build_agent_win32
--ignore-dir=build_manager
--ignore-dir=packaging
--ignore-dir=RPMBUILD
$ ack --version
ack 1.90
Running under Perl 5.8.5 at /usr/bin/perl
...

Thanks for any help!

--
Packy Anderson

Email:  PackyA...@gmail.com
GVoice: (646) 833-8832

packy

unread,
Sep 21, 2009, 11:36:05 PM9/21/09
to ack dev/users
On Sep 18, 12:49 pm, Packy Anderson <packyander...@gmail.com> wrote:
> I'm using the single-file 1.90 running out of my $HOME/bin. Unfortunately,
> it's not using the pager. I'll ack for some common string in my codebase,
> and the results scroll off the screen. I could swear it was working before
> I upgraded to 1.90...

I found the problem. Somewhere leading up to v1.90, ack switched over
from having a $to_screen package variable to having a $output_to_pipe
variable that reversed the sense of the test, but the code in
set_up_pager() didn't similarly reverse the sense. So, while the
older code had:

sub set_up_pager {
my $command = shift;

return unless $to_screen;
# set up the pager
}


Version 1.90 had:

sub set_up_pager {
my $command = shift;

return unless App::Ack::output_to_pipe();
# set up the pager
}

This is easily fixed by switching the unless to an if:

$ git diff
diff --git a/Ack.pm b/Ack.pm
index ae43146..260482e 100644
--- a/Ack.pm
+++ b/Ack.pm
@@ -1476,7 +1476,7 @@ sub get_iterator {
sub set_up_pager {
my $command = shift;

- return unless App::Ack::output_to_pipe();
+ return if App::Ack::output_to_pipe();

my $pager;
if ( not open( $pager, '|-', $command ) ) {
diff --git a/ack b/ack
index 239bcaa..78e8cec 100755
--- a/ack
+++ b/ack
@@ -2319,7 +2319,7 @@ sub get_iterator {
sub set_up_pager {
my $command = shift;

- return unless App::Ack::output_to_pipe();
+ return if App::Ack::output_to_pipe();

my $pager;
if ( not open( $pager, '|-', $command ) ) {



And now the pager works.

Later!
-packy

Andy Lester

unread,
Sep 25, 2009, 4:09:59 PM9/25/09
to ack-...@googlegroups.com
>>
> I found the problem. Somewhere leading up to v1.90, ack switched over
> from having a $to_screen package variable to having a $output_to_pipe
> variable that reversed the sense of the test, but the code in
> set_up_pager() didn't similarly reverse the sense.

Sorry about that. It's been patched and pushed.

xoxo,
Andy


--
Andy Lester => an...@petdance.com => www.theworkinggeek.com => AIM:petdance


Reply all
Reply to author
Forward
0 new messages