2

I'd like to take the csearch output and color it. It looks like so:

/home/bp/whatever.txt:1:foo

And this works:

csearch -n -- $term \
  | env GREP_COLORS='mt=02;35' grep --color=always -P '^[^:]+:[^:]+:' \
  | grep -P --color=always -- $term \
  | less -RFX

However, it waits for the full output of csearch to be computed before anything is shown.

Now, if I do this:

csearch -n -- $term \
  | env GREP_COLORS='mt=02;35' grep --color=always -P '^[^:]+:[^:]+:' \
  | pv
  | grep -P --color=always -- $term \
  | less -RFX

...I can see the data flowing, but if I do this:

csearch -n -- $term \
  | env GREP_COLORS='mt=02;35' grep --color=always -P '^[^:]+:[^:]+:' \
  | grep -P --color=always -- $term \
  | pv
  | less -RFX

...no data is flowing. The second grep seems to be waiting for an EOF.

Adding --line-buffered to both grep's seems to be doing me no good.

Why is this command pipe waiting for EOF?

1
  • …do you think mistaking an executable for a glorified builtin is a typo, or a sporadic issue that went on its own?
    – badp
    Commented Aug 24, 2016 at 1:05

1 Answer 1

7

I was using fish, which means I wasn't actually using grep, but:

function grep
    command grep --color=auto $argv
end

and fish code blocks do not stream their output.

This wasn't a problem in the first grep since it was already wrapped by env, so it ignored this function.

Changing grep to /bin/grep fixed it.

2
  • This is fish issue #2007.
    – faho
    Commented Aug 23, 2016 at 23:39
  • @faho or rather #1396 :)
    – badp
    Commented Aug 24, 2016 at 1:01

Not the answer you're looking for? Browse other questions tagged .