aws / aws/aws-cli

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

Open
#9,526 9 comments 1 reaction 0 assignees View on GitHub
feature-request p3 s3
Dominant language
Python
Stars
17.3k
Forks
4.6k
Avg merge
1d 2h
Merged PRs (30d)
13

Description

### 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](https://github.com/user-attachments/assets/41c019ea-85b4-4ab4-9ae2-d1a260cc3a4b)

The `^M` is how `less` represents these ANSI escapes

### Reproduction Steps

`aws s3 cp ./foo s3://bar/ >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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.