[GH-ISSUE #3356] Terminal control codes in progress messages should be optional #2107

Closed
opened 2026-05-05 08:47:09 -06:00 by gitea-mirror · 4 comments
Owner

Originally created by @rdiez on GitHub (Apr 15, 2020).
Original GitHub issue: https://github.com/netblue30/firejail/issues/3356

Firejail outputs some terminal control codes when printing information:

------8<------8<------8<------
$ firejail --noprofile sh -c "echo a"

^[]0;firejail sh -c echo a ^Ga
Parent pid 21368, child pid 21369

Parent is shutting down, bye...
------8<------8<------8<------

Note the "^[]0;" at the beginning: Those are escape characters for some terminal. And the same with "^Ga" at the end.

I do not know what the codes are for. They do not seem to colourise the ouput, which is what applications usually do with such control codes.

Such "garbage" shows up in log files and is unsightly. The first reaction is suspicion of data corruption.

Firejail should at least check whether STDOUT is a terminal before outputting such colour or terminal codes.

Other tools like Git offer more control, see for example:
git -c color.ui=always status

I suggest implementing an option like command "ls" does:

------8<------8<------8<------

--color[=WHEN]
colorize the output; WHEN can be 'always' (default if omitted), 'auto', or 'never'; more info below

Using color to distinguish file types is disabled both by default and with --color=never. With --color=auto, ls emits color codes only when standard output is connected to a
terminal. The LS_COLORS environment variable can change the settings. Use the dircolors command to set it.

------8<------8<------8<------

This issue was mentioned first in bug #3354.

I have tested this with the latest Firejail release version 0.9.62.

Originally created by @rdiez on GitHub (Apr 15, 2020). Original GitHub issue: https://github.com/netblue30/firejail/issues/3356 Firejail outputs some terminal control codes when printing information: ------8<------8<------8<------ $ firejail --noprofile sh -c "echo a" ^[]0;firejail sh -c echo a ^Ga Parent pid 21368, child pid 21369 Parent is shutting down, bye... ------8<------8<------8<------ Note the "^[]0;" at the beginning: Those are escape characters for some terminal. And the same with "^Ga" at the end. I do not know what the codes are for. They do not seem to colourise the ouput, which is what applications usually do with such control codes. Such "garbage" shows up in log files and is unsightly. The first reaction is suspicion of data corruption. Firejail should at least check whether STDOUT is a terminal before outputting such colour or terminal codes. Other tools like Git offer more control, see for example: git -c color.ui=always status I suggest implementing an option like command "ls" does: ------8<------8<------8<------ --color[=WHEN] colorize the output; WHEN can be 'always' (default if omitted), 'auto', or 'never'; more info below Using color to distinguish file types is disabled both by default and with --color=never. With --color=auto, ls emits color codes only when standard output is connected to a terminal. The LS_COLORS environment variable can change the settings. Use the dircolors command to set it. ------8<------8<------8<------ This issue was mentioned first in bug #3354. I have tested this with the latest Firejail release version 0.9.62.
gitea-mirror 2026-05-05 08:47:09 -06:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@smitsohu commented on GitHub (Aug 28, 2020):

For some reason I cannot reproduce, but it has been reported before.

Suspect:
5014a434e5/src/firejail/env.c (L160-L162)

<!-- gh-comment-id:682834917 --> @smitsohu commented on GitHub (Aug 28, 2020): For some reason I cannot reproduce, but it has been reported before. Suspect: https://github.com/netblue30/firejail/blob/5014a434e5b0a735a7fcd4a1170408337fe4fc09/src/firejail/env.c#L160-L162
Author
Owner

@rusty-snake commented on GitHub (Aug 28, 2020):

@smitsohu If they are printed to the terminal your can't see they, try to firejail --noprofile true | less or firejail --noprofile true > foo && vim foo.

<!-- gh-comment-id:682923911 --> @rusty-snake commented on GitHub (Aug 28, 2020): @smitsohu If they are printed to the terminal your can't see they, try to `firejail --noprofile true | less` or `firejail --noprofile true > foo && vim foo`.
Author
Owner

@smitsohu commented on GitHub (Aug 28, 2020):

@rusty-snake Thanks, now I have it!

That code in env.c is indeed the reason for this artifact. As it doesn't make sense to inject escape sequences if stdout is not a terminal, I agree that a minimal fix should check this first.

<!-- gh-comment-id:682973757 --> @smitsohu commented on GitHub (Aug 28, 2020): @rusty-snake Thanks, now I have it! That code in env.c is indeed the reason for this artifact. As it doesn't make sense to inject escape sequences if stdout is not a terminal, I agree that a minimal fix should check this first.
Author
Owner

@smitsohu commented on GitHub (Aug 29, 2020):

Thanks for reporting the bug!

<!-- gh-comment-id:683333104 --> @smitsohu commented on GitHub (Aug 29, 2020): Thanks for reporting the bug!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/firejail#2107
No description provided.