beyondgrep/ack1

ack doesn't accept input from bash process substitutions

rsimoes opened this issue · 6 comments

cf grep:

$ grep gnome <(ps aux)
rsimoes   1802  0.0  0.2 191684 13588 ?        SLl  Apr04   0:00 /usr/bin/gnome-keyring-daemon --daemonize --login
rsimoes   1814  0.0  0.1 265632  9748 ?        Ssl  Apr04   0:00 /usr/bin/gnome-session --session=ubuntu
...

How are you calling ack? Can you please provide an actual command line and results?

I'm using it in an identical form as the grep call above, so there may be a difference in default behavior I'm not aware of:
$ ack gnome <(ps aux)
(no output)

I'm sorry about that. Here I thought we'd gone through just about every permutation of dealing with the shell and having ack properly handle it. :-(

I had to read up on named pipes to figure this out. When you run grep blah <(ps ax), it's running the command grep blah /dev/fd/whatever. The output of ps is sent to that file, but fstat()ing that file gave me a length of zero. Fortunately, I could still read from the file. Also, the struct returned by fstat() contains an st_mode, which is true for named pipes when binary ANDed with S_IFIFO.

You can see the entire fix in C here: https://github.com/ggreer/the_silver_searcher/pull/23/files

My perl-fu is weak, so I'm sorry I can't give you any pointers on how to fix this in ack.

The new version of File::Next, version 1.08, supports named pipes. You should be able to install File::Next and ack should now handle named pipes. This will only be if you are NOT using the standalone version.

Thsi should now be working in ack 2.