I'm guessing this has nothing to do with ack
but more with bash
:
Here we create file.txt
containing the string foobar
soack
can find foobar
in it:
> echo foobar > file.txt
> echo 'ack foobar file.txt' > ack.sh
> bash ack.sh
foobar
> bash < ack.sh
foobar
So far so good. But why doesn't ack find anything in it like this?
> cat ack.sh | bash
(no output)
or
> echo 'ack foobar file.txt' | bash
(no output)
Why doesn't ack
find foobar
in the last two cases?
Adding unbuffer
(from expect) in front makes it work, which I don't understand:
> echo 'unbuffer ack foobar file.txt' | bash
foobar
Even stranger:
> cat ack2.sh
echo running
ack foobar file.txt
echo running again
unbuffer ack foobar file.txt
# Behaves as I'd expect
> bash ack2.sh
running
foobar
running again
foobar
# Strange output
> cat ack2.sh | bash
running
unbuffer ack foobar file.txt
What's up with this output? It echos unbuffer ack foobar file.txt
but not running again
? Huh?
ack
issue. Try to replaceack
bygrep
and it works as expected. – Thermocouplecat ack.sh | bash
. I'd file file a bug forack
. Or just usegrep
;) – Thermocoupleecho 'ack foobar file.txt <&-' | bash
orecho 'ack foobar file.txt </dev/null' | bash
– Alternate