Skip to content

Allow Godot to always print stderr colors #12507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Cykyrios opened this issue May 27, 2025 · 0 comments · May be fixed by godotengine/godot#106868 or godotengine/godot#77261
Open

Allow Godot to always print stderr colors #12507

Cykyrios opened this issue May 27, 2025 · 0 comments · May be fixed by godotengine/godot#106868 or godotengine/godot#77261

Comments

@Cykyrios
Copy link

Describe the project you are working on

A commandline tool (which calls a shell script, which itself calls another Godot commandline script).

Describe the problem or limitation you are having in your project

Godot prints warnings and errors with useful colors to stderr, so they pop out and are easily readable in terminals/logs. When you pipe a Godot script with OS.execute_with_pipe, however, colors are stripped from stderr, as evidenced in os_unix.cpp. This means the output cannot have its original colors, which makes reading errors in the terminal (or CI logs) cumbersome.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Add an option to always include colors, such as godot --color or any appropriate keyword, or godot --color=always like you would find in other commands such as ls.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Here's a comparison without and with colors, all the text visible here is printed with stdio.printraw and stderr.printraw, which are obtained from OS.execute_with_pipe.
Before (note a single colored line, which was obtained with print_rich):
Image
After:
Image

This result was obtained by simply removing the TTY check in os_unix.cpp, but this should instead depend on the proposed --color option passed to Godot. The shell script would therefore include a line such as:

godot --headless --color -s ./my_script.gd

If this enhancement will not be used often, can it be worked around with a few lines of script?

I think the only workaround would be to regex stderr to find and color the text.

Is there a reason why this should be core and not an add-on in the asset library?

This is about exposing an already existing core feature to piped stderr, I don't think an addon would make much sense for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants