-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Description
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!.