Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/uu/sort/locales/en-US.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ sort-after-help = The key format is FIELD[.CHAR][OPTIONS][,FIELD[.CHAR]][OPTIONS
sort-open-failed = open failed: {$path}: {$error}
sort-parse-key-error = failed to parse key {$key}: {$msg}
sort-cannot-read = cannot read: {$path}: {$error}
sort-read-failed = read failed: {$error}
sort-open-tmp-file-failed = failed to open temporary file: {$error}
Comment thread
arcusbuilds marked this conversation as resolved.
sort-compress-prog-execution-failed = could not run compress program '{$prog}': {$error}
sort-compress-prog-terminated-abnormally = {$prog} terminated abnormally
Expand Down
1 change: 1 addition & 0 deletions src/uu/sort/locales/fr-FR.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ sort-after-help = Le format de clé est CHAMP[.CAR][OPTIONS][,CHAMP[.CAR]][OPTIO
sort-open-failed = échec d'ouverture : {$path} : {$error}
sort-parse-key-error = échec d'analyse de la clé {$key} : {$msg}
sort-cannot-read = impossible de lire : {$path} : {$error}
sort-read-failed = échec de lecture : {$error}
sort-open-tmp-file-failed = échec d'ouverture du fichier temporaire : {$error}
sort-compress-prog-execution-failed = impossible d'exécuter le programme de compression '{$prog}' : {$error}
sort-compress-prog-terminated-abnormally = {$prog} s'est terminé anormalement
Expand Down
10 changes: 8 additions & 2 deletions src/uu/sort/src/chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ use std::{

use memchr::memchr_iter;
use self_cell::self_cell;
use uucore::error::{UResult, USimpleError};
use uucore::error::{UResult, USimpleError, strip_errno};
use uucore::translate;

use crate::{
GeneralBigDecimalParseResult, GlobalSettings, Line, SortMode, numeric_str_cmp::NumInfo,
Expand Down Expand Up @@ -427,7 +428,12 @@ fn read_to_buffer<T: Read>(
Err(e) if e.kind() == ErrorKind::Interrupted => {
// retry
}
Err(e) => return Err(USimpleError::new(2, e.to_string())),
Err(e) => {
return Err(USimpleError::new(
2,
translate!("sort-read-failed", "error" => strip_errno(&e)),
));
}
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions tests/by-util/test_sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,18 @@ fn test_merge_write_error_does_not_panic() {
}
}

// A read error must be reported with context and without the raw io::Error suffix.
// It used to print `sort: Input/output error (os error 5)`.
#[test]
#[cfg(target_os = "linux")]
fn test_read_error_message() {
// Reading /proc/self/mem from offset 0 fails with EIO.
new_ucmd!()
.arg("/proc/self/mem")
.fails_with_code(2)
.stderr_only("sort: read failed: Input/output error\n");
}

#[test]
fn test_merge_unique() {
new_ucmd!()
Expand Down
Loading