Do not issue ANSI escapes if stdout is not connected to terminal
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
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
Hello @septatrix, thanks for reaching out. We are currently working on this/handing proper readable output. We don't have a timeline for now on the release but please ensure to check our changelog for updates moving forward: https://raw.githubusercontent.com/aws/aws-cli/v2/CHANGELOG.rst . Thank you.
Greetings! It looks like this issue hasn’t been active in longer than five days. We encourage you to check if this is still an issue in the latest release. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or upvote with a reaction on the initial post to prevent automatic closure. If the issue is already closed, please feel free to open a new one.
Does not seem to be fixed yet
Also not sure why this is tagged with "response-requested"?
Retried the command: aws s3 cp ./testfile.bin s3://<bucket-name>/ &> log.txt and aws s3 cp --no-progress ./foo s3://bar/ 2>log.txt and there was no ANSI escape. Are you still seeing the escapes? If so, what is the command to repro?
I still see them using any of:
aws s3 cp s3://<bucket>/<file> . | less
aws s3 cp s3://<bucket>/<file> . | cat -A
systemd-run --user --unit aws-s3-test --same-dir \
-E AWS_ACCESS_KEY_ID=... -E AWS_SECRET_ACCESS_KEY=... -E AWS_ENDPOINT_URL=... \
.venv/bin/aws s3 cp s3://<bucket>/<file> . \
&& journalctl --user --unit aws-s3-test # here it shows up as "aws[<PID>]: [3.7K blob data]"
Hello @septatrix, from CLI Version2: 2.31.0 :
enhancement:``s3``: Add controls over progress status message frequency and multiline printing
Adding --progress-multiline show progress on multiple lines rather than one line, shown here on s3 cp command.
That's great, now the only thing missing is to automatically infer that flag when we detect that stdout is not a terminal
The team has decided to plan for this feature request. We do not have a timeline yet and this issue will remain open for tracking.