Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the auto capitalization of error message #5004

Merged
merged 1 commit into from
Jun 25, 2023
Merged
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
11 changes: 1 addition & 10 deletions src/uucore/src/lib/mods/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ impl Display for UIoError {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> {
use std::io::ErrorKind::*;

let mut message;
let message;
let message = if self.inner.raw_os_error().is_some() {
// These are errors that come directly from the OS.
// We want to normalize their messages across systems,
Expand Down Expand Up @@ -424,7 +424,6 @@ impl Display for UIoError {
// (https:/rust-lang/rust/issues/86442)
// are stabilized, we should add them to the match statement.
message = strip_errno(&self.inner);
capitalize(&mut message);
&message
}
}
Expand All @@ -435,7 +434,6 @@ impl Display for UIoError {
// a file that was not found.
// There are also errors with entirely custom messages.
message = self.inner.to_string();
capitalize(&mut message);
&message
};
if let Some(ctx) = &self.context {
Expand All @@ -446,13 +444,6 @@ impl Display for UIoError {
}
}

/// Capitalize the first character of an ASCII string.
fn capitalize(text: &mut str) {
if let Some(first) = text.get_mut(..1) {
first.make_ascii_uppercase();
}
}

/// Strip the trailing " (os error XX)" from io error strings.
pub fn strip_errno(err: &std::io::Error) -> String {
let mut msg = err.to_string();
Expand Down
2 changes: 1 addition & 1 deletion tests/by-util/test_cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2724,7 +2724,7 @@ fn test_copy_dir_preserve_permissions_inaccessible_file() {
ucmd.args(&["-p", "-R", "d1", "d2"])
.fails()
.code_is(1)
.stderr_only("cp: cannot open 'd1/f' for reading: Permission denied\n");
.stderr_only("cp: cannot open 'd1/f' for reading: permission denied\n");
assert!(at.dir_exists("d2"));
assert!(!at.file_exists("d2/f"));

Expand Down