mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
tee: fix < . message and strip errno
This commit is contained in:
@@ -14,7 +14,7 @@ tee-help-output-error-exit = exit on write errors to any output
|
||||
tee-help-output-error-exit-nopipe = exit on write errors to any output that are not pipe errors (equivalent to exit on non-unix platforms)
|
||||
|
||||
# Error messages
|
||||
tee-error-stdin = stdin: { $error }
|
||||
tee-error-stdin = read error: { $error }
|
||||
|
||||
# Other messages
|
||||
tee-standard-output = 'standard output'
|
||||
|
||||
@@ -14,7 +14,7 @@ tee-help-output-error-exit = quitter en cas d'erreurs d'écriture vers toute sor
|
||||
tee-help-output-error-exit-nopipe = quitter en cas d'erreurs d'écriture vers toute sortie qui ne sont pas des erreurs de tube (équivalent à exit sur les plateformes non-unix)
|
||||
|
||||
# Messages d'erreur
|
||||
tee-error-stdin = stdin : { $error }
|
||||
tee-error-stdin = erreur de lecture: { $error }
|
||||
|
||||
# Autres messages
|
||||
tee-standard-output = 'sortie standard'
|
||||
|
||||
@@ -9,7 +9,7 @@ use std::fs::OpenOptions;
|
||||
use std::io::{Error, ErrorKind, Read, Result, Write, stderr, stdin, stdout};
|
||||
use std::path::PathBuf;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::UResult;
|
||||
use uucore::error::{UResult, strip_errno};
|
||||
use uucore::format_usage;
|
||||
use uucore::parser::shortcut_value_parser::ShortcutValueParser;
|
||||
use uucore::translate;
|
||||
@@ -431,7 +431,11 @@ impl Read for NamedReader {
|
||||
fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
|
||||
match self.inner.read(buf) {
|
||||
Err(f) => {
|
||||
let _ = writeln!(stderr(), "{}", translate!("tee-error-stdin", "error" => f));
|
||||
let _ = writeln!(
|
||||
stderr(),
|
||||
"tee: {}",
|
||||
translate!("tee-error-stdin", "error" => strip_errno(&f))
|
||||
);
|
||||
Err(f)
|
||||
}
|
||||
okay => okay,
|
||||
|
||||
@@ -16,6 +16,15 @@ use std::time::Duration;
|
||||
|
||||
// spell-checker:ignore nopipe
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn test_error_stdin_directory() {
|
||||
new_ucmd!()
|
||||
.set_stdin(std::fs::File::open(".").unwrap())
|
||||
.fails_with_code(1)
|
||||
.stderr_is("tee: read error: Is a directory\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
new_ucmd!().arg("--definitely-invalid").fails_with_code(1);
|
||||
|
||||
Reference in New Issue
Block a user