-
Improvement
-
Resolution: Unresolved
-
Minor
-
None
-
3.9.4, 3.10.1, 3.11
-
None
-
MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_39_STABLE
In the cli_ansi_format() function we should check for presence of a tty using posix_isatty(STDOUT). If STDOUT is not a tty, then we should do the same replacement as on Windows, and replace all ANSI codes with ''.
As it stands, if you pipe any script which includes ANSI characters to a program, or a file, you will end up with content like:
[-------------------------------------------------------] 0%
|
^[[1A^[[1A0%
|
[^[[0;34m^[[0;0m-------------------------------------------------------] 0.0%
|
^[[1A^[[1AYou are up to 0.0 out of 100
|
[^[[0;34m^[[0;0m-------------------------------------------------------] 0.0%
|
^[[1A^[[1AYou are up to 4.0 out of 100
|
[^[[0;34m██^[[0;0m-----------------------------------------------------] 4.0% - 5 secs
|
^[[1A^[[1AYou are up to 8.0 out of 100
|
[^[[0;34m████^[[0;0m---------------------------------------------------] 8.0% - 4 secs
|
^[[1A^[[1AYou are up to 12.0 out of 100
|
[^[[0;34m███████^[[0;0m------------------------------------------------] 12.0% - 3 secs
|
^[[1A^[[1AYou are up to 16.0 out of 100
|
[^[[0;34m█████████^[[0;0m----------------------------------------------] 16.0% - 3 secs
|
^[[1A^[[1AYou are up to 20.0 out of 100
|
[^[[0;34m███████████^[[0;0m--------------------------------------------] 20.0% - 3 secs
|
^[[1A^[[1AYou are up to 24.0 out of 100
|
- Discovered while testing
-
MDL-70583 Implement a renderer for progress_bar in cli output
- Closed