Skip to content

flush grcat line writes#62

Open
dperny wants to merge 1 commit intogarabik:masterfrom
dperny:master
Open

flush grcat line writes#62
dperny wants to merge 1 commit intogarabik:masterfrom
dperny:master

Conversation

@dperny
Copy link

@dperny dperny commented May 24, 2017

I used grc in a Docker container that runs go tests. I have a configuration that correctly colorizes my tests. However, the output of grc go test -v does not get written until the tests all finish, unless the container is run with a TTY. Adding flush=True to the print function in grcat causes the output to be written out line-by-line as lines become available without a TTY.

I don't know how this affects things like performance or what side effects it has. You may want to instead write a patch that gates this behavior behind a flag. I'm not sure what the correct behavior is. I'm using this fork for my stuff and it works fine for me.

@trinitronx
Copy link

I'm wondering if this is also the reason for the behavior of read prompt not printing in #82

@luisdavim
Copy link
Contributor

I think using flush is a good idea.

@trinitronx
Copy link

So I ended up doing some debugging because I ran into bug #82 again today.

I think this PR is a good idea too... unfortunately it's not related to #82.

I tried testing with this change and adding a debug statement before it prints the line. Yet, even with print( ... , flush=True) grc still behaves the same as in #82 .

For example:

        try:
            print('GRC: printing line with flush', flush=True)
            print(nline, flush=True)

I tested this make target that uses the Bash builtin read -p 'Enter FOO: ' FOO, and with the following aliases:

$ type make
make is aliased to `colourify make'
$ type colourify
colourify is aliased to `/usr/local/bin/grc -es --colour=auto'

Running make foo still does not show the prompt. It does show the debug output happening:

make foo
GRC: printing line with flush
echo 'hello from foo.sh'
^CGRC: printing line with flush
Enter FOO: make: *** [provision] Interrupt: 2

So, this shouldn't hurt anything to use flush=True but I guess it doesn't fix #82 either. The only thing I can find that affects colourify make read -p "Prompt" behavior is removing the -es flags from colourify alias:

alias colourify '/usr/local/bin/grc  --colour=auto'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants