Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-70709

cli_ansi_format() should detect absence of a tty

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Unresolved
    • Minor
    • None
    • 3.9.4, 3.10.1, 3.11
    • Administration
    • None
    • MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_39_STABLE

    Description

      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
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              dobedobedoh Andrew Lyons
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Clockify

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.