aws / aws/aws-cli

Broken pipe error when piping "s3 ls" output to grep -q

Open
#5,899 15 comments 19 reactions 0 assignees View on GitHub
bug community contribution-ready p2 s3
Dominant language
Python
Stars
17.3k
Forks
4.6k
Avg merge
1d 2h
Merged PRs (30d)
13

Description

Confirm by changing [ ] to [x] below to ensure that it's a bug:
- [x] I've gone though the [User Guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html) and the [API reference](https://docs.aws.amazon.com/cli/latest/reference/)
- [x] I've searched for [previous similar issues](https://github.com/aws/aws-cli/issues) and didn't find any solution

**Describe the bug**
`[Errno 32] Broken pipe` is raised when `aws s3 ls` output is piped to `grep -q` and the matching string is found; exit code is 255.

**SDK version number**
aws-cli/1.18.220 Python/2.7.17 botocore/1.19.60

**Platform/OS/Hardware/Device**
Linux/4.15.0-134-generic x86_64, Ubuntu 18.04.5 LTS

**To Reproduce (observed behavior)**
Steps to reproduce the behavior

set -o pipefail; aws s3 ls s3://SOME_S3_PATH | grep -q SOME_STR; echo $?
[Errno 32] Broken pipe
255

**Expected behavior**
No failure, just a clean exit with code 0.

**Additional context**
Command `grep -q` will stop immediately after the first match, and the program which is writing to the pipe will receive SIGPIPE. It is clear, that in case of `s3 ls` this signal can be ignored.

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.