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 output when run in a loop. #474

Closed tthomas7 closed 5 years ago

tthomas7 commented 10 years ago

Redirecting stdin from a file works as expected but piping from another command returns immediately as if nothing was found.

while read -r line; do Ack "$line"; done < search_terms finds the search terms listed in the file.

cat search_terms | while read -r line; do Ack "$line"; done; returns immediately.

petdance commented 10 years ago

Why are you calling Ack instead of ack?

tthomas7 commented 10 years ago

that's a good question. I didn't know there was a difference

petdance commented 10 years ago

Might be, might not be. Do you have some sort of Ack alias that aliases to ack or something? What OS are you on? Do you just have a case-insensitive filesystem?

tthomas7 commented 10 years ago

I'm using OSX and zsh, it is case insensitive I believe. I just tried LS and that works and ack doesn't change the behavior.

ghost commented 10 years ago

@tthomas7 that's a good question. I didn't know there was a difference

On Linux and other Unixoid systems there is a difference between lowercase and uppercase command.

petdance commented 10 years ago

The Mac HFS+ filesystem is case-insensitive, by default I believe, so that explains that.

hleeldc commented 10 years ago

I think it has something to do with this line: https://github.com/petdance/ack2/blob/dev/Ack.pm#L47

$is_filter_mode = -p STDIN;

This evaluates to 1 (true) when STDIN is from a pipe. Because of this, ack expects data to search from STDIN.

petdance commented 7 years ago

So this is our old nemesis "figuring out if we're filtering or not".