You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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 makeread -p "Prompt" behavior is removing the -es flags from colourify alias:
alias colourify '/usr/local/bin/grc --colour=auto'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I used
grcin a Docker container that runs go tests. I have a configuration that correctly colorizes my tests. However, the output ofgrc go test -vdoes not get written until the tests all finish, unless the container is run with a TTY. Addingflush=Trueto the print function ingrcatcauses 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.