Skip to content

fold: does not handle broken pipe in the same way as GNU #10230

Description

@ngtv2409

Component

fold

Description

GNU fold lets the kernel kill the pipeline cleanly without any extra handling steps while UU fold handles the broken pipe, prints fold: broken pipe and exit with code 1.

Reproduction

To simulate a broken pipe, we can use this command
yes a | fold -w1 | head -n1. yes a creates an infinite stream of as for fold -w1 whose output is piped to head -n1, which terminate after the first line of output, thus create a broken pipe where reader is terminated unexpectedly.

Using the GNU implementation, nothing happens beside code 141 when bash set -o pipefail.

$ yes a | fold -w1 | head -n1
a
$ echo $?
141
$ yes a | uu fold -w1 | head -n1
a
fold: Broken pipe
$ echo $?
1

Impact

A behavioral difference to GNU coreutils

Note

The handling of errors seem to be located in uucore::error meaning this issue may affect many other utilities.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions