Closed tthomas7 closed 5 years ago
Why are you calling Ack
instead of ack
?
that's a good question. I didn't know there was a difference
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?
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.
@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.
The Mac HFS+ filesystem is case-insensitive, by default I believe, so that explains that.
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.
So this is our old nemesis "figuring out if we're filtering or not".
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.