Skip to content

Do not issue ANSI escapes if stdout is not connected to terminal #9526

Open
@septatrix

Description

@septatrix

Describe the bug

When invoking commands like aws s3 cp from scripts, the program issues ANSI sequences like the one for the progress notification (i.e. move cursor back to start of line). If these scripts not log their output to a file they instead result in a jumbled mess which is hard to read

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

If stdout/stderr is not connected to a terminal the CLI should either a) automatically infer --no-progress, or b) write each progress update on a new line

Current Behavior

Image

The ^M is how less represents these ANSI escapes

Reproduction Steps

aws s3 cp --no-progress ./foo s3://bar/ 2>log.txt

Possible Solution

This can be somewhat mitigated by explicitly using --no-progress but doing so obviously hides any progress

Additional Information/Context

No response

CLI version used

awscli2-2.25.0

Environment details (OS name and version, etc.)

Fedora 42

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.needs-triageThis issue or PR still needs to be triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions