[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Possible bug with grep/sed/tail?

From: Jim Meyering
Subject: Re: Possible bug with grep/sed/tail?
Date: Sat, 22 Nov 2008 13:17:18 +0100

Jim Meyering <address@hidden> wrote:
> Andreas Schwab <address@hidden> wrote:
>> Paolo Bonzini <address@hidden> writes:
>>>   alias line-buffer='preload /t/linebuf.so'
>> If you end the alias expansion with a space then the next word is also
>> expanded as an alias.
> Ah, yes.  That was it.  Thanks ;-)

To summarize, here's what I'm using, now:

Put the following in your .bashrc or .zshrc file:

  # Create the .so file with the following.
    echo '__attribute__((constructor))void f(){setvbuf(stdout,NULL,_IOLBF,0);}' 
      | gcc -s -include stdio.h -x c - -fPIC -shared -o "$line_buffer_so"
  alias line-buffer="LD_PRELOAD='$line_buffer_so' "

As a one-time set-up, you have to run the line-buffer-init function.
Then you can use it e.g., to watch *interactively* filtered tail -f output.
For example, watch for warnings in build output like this:

    make >& log & line-buffer tail -F log | grep warning:

but that's not quite right, since it hangs forever.
Add --pid=$! to make tail stop when the parent (make) process dies:

    make >& log & line-buffer tail -F log --pid=$! | grep warning:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]