Skip to content

fail!() writes to stderr #374

Description

@mahkoh

fail! writes an error message to stderr. Every function call that can fail is a potential rust error message to stderr. Consider the following code

~/rust/coreutils/build$ ./cat /etc/fstab | grep -L 
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.
task '<main>' failed at 'called `Result::unwrap()` on an `Err` value: broken pipe (Broken pipe)', /build/rust-git/src/rust/src/libcore/result.rs:548

This is not how cat should behave. There are currently 129 calls to unwrap() in coreutils.

There is currently no way to make fail! simply call abort which would probably be sufficient for coreutils. You can use stdio::set_stderr to set the writer used by fail!() or you can remove every call that can fail.

Note that println! will also call fail on sigpipe. There are currently 420 occurrences of println!.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions