Skip to content
Draft
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
6 changes: 3 additions & 3 deletions src/uu/chcon/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ pub(crate) enum Error {
#[error(transparent)]
CommandLine(#[from] clap::Error),

#[error("{}", translate!("chcon-error-operation-failed", "operation" => operation.clone()))]
#[error("{}", translate!("chcon-error-operation-failed", "operation" => operation))]
SELinux {
operation: String,
#[source]
source: selinux::errors::Error,
},

#[error("{}", translate!("chcon-error-operation-failed", "operation" => operation.clone()))]
#[error("{}", translate!("chcon-error-operation-failed", "operation" => operation))]
Io {
operation: String,
#[source]
source: io::Error,
},

#[error("{}", translate!("chcon-error-operation-failed-on", "operation" => operation.clone(), "operand" => operand1.quote()))]
#[error("{}", translate!("chcon-error-operation-failed-on", "operation" => operation, "operand" => operand1.quote()))]
Io1 {
operation: String,
operand1: OsString,
Expand Down
2 changes: 1 addition & 1 deletion src/uu/chmod/src/chmod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ enum ChmodError {
PreserveRootSameAs(PathBuf),
#[error("{}", translate!("chmod-error-permission-denied", "file" => _0.quote()))]
PermissionDenied(PathBuf),
#[error("{}", translate!("chmod-error-new-permissions", "file" => _0.maybe_quote(), "actual" => _1.clone(), "expected" => _2.clone()))]
#[error("{}", translate!("chmod-error-new-permissions", "file" => _0.maybe_quote(), "actual" => _1, "expected" => _2))]
NewPermissions(PathBuf, String, String),
#[error("{}", translate!("chmod-error-changing-permissions", "file" => _0.quote(), "err" => strip_errno(_1)))]
ChangingPermissions(PathBuf, std::io::Error),
Expand Down
8 changes: 4 additions & 4 deletions src/uu/cp/src/cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl Display for BackupError {
write!(
f,
"{}",
translate!("cp-error-backup-format", "error" => self.0.clone(), "exec" => uucore::execution_phrase())
translate!("cp-error-backup-format", "error" => self.0, "exec" => uucore::execution_phrase())
)
}
}
Expand Down Expand Up @@ -1089,9 +1089,9 @@ impl Options {
.get_one::<String>(update_control::arguments::OPT_UPDATE)
.is_some_and(|v| v == "none" || v == "none-fail")
{
return Err(CpError::InvalidArgument(
translate!("cp-error-invalid-backup-argument").to_string(),
));
return Err(CpError::InvalidArgument(translate!(
"cp-error-invalid-backup-argument"
)));
}

let backup_suffix = backup_control::determine_backup_suffix(matches);
Expand Down
4 changes: 1 addition & 3 deletions src/uu/cp/src/platform/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ pub(crate) fn copy_on_write(
nofollow: bool,
) -> CopyResult<CopyDebug> {
if sparse_mode != SparseMode::Auto {
return Err(translate!("cp-error-sparse-not-supported")
.to_string()
.into());
return Err(translate!("cp-error-sparse-not-supported").into());
}
let mut copy_debug = CopyDebug {
offload: OffloadReflinkDebug::Unknown,
Expand Down
20 changes: 10 additions & 10 deletions src/uu/dd/src/parseargs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use uucore::translate;
/// Parser Errors describe errors with parser input
#[derive(Debug, PartialEq, Eq, Error)]
pub enum ParseError {
#[error("{}", translate!("dd-error-unrecognized-operand", "operand" => .0.clone()))]
#[error("{}", translate!("dd-error-unrecognized-operand", "operand" => .0))]
UnrecognizedOperand(String),
#[error("{}", translate!("dd-error-multiple-format-table"))]
MultipleFmtTable,
Expand All @@ -30,25 +30,25 @@ pub enum ParseError {
MultipleBlockUnblock,
#[error("{}", translate!("dd-error-multiple-excl"))]
MultipleExclNoCreate,
#[error("{}", translate!("dd-error-invalid-flag", "flag" => .0.clone()))]
#[error("{}", translate!("dd-error-invalid-flag", "flag" => .0))]
FlagNoMatch(String),
#[error("{}", translate!("dd-error-invalid-output-flag", "flag" => .0.clone()))]
#[error("{}", translate!("dd-error-invalid-output-flag", "flag" => .0))]
OutputFlagNoMatch(String),
#[error("{}", translate!("dd-error-conv-flag-no-match", "flag" => .0.clone()))]
#[error("{}", translate!("dd-error-conv-flag-no-match", "flag" => .0))]
ConvFlagNoMatch(String),
#[error("{}", translate!("dd-error-multiplier-parse-failure", "input" => .0.clone()))]
#[error("{}", translate!("dd-error-multiplier-parse-failure", "input" => .0))]
MultiplierStringParseFailure(String),
#[error("{}", translate!("dd-error-multiplier-overflow", "input" => .0.clone()))]
#[error("{}", translate!("dd-error-multiplier-overflow", "input" => .0))]
MultiplierStringOverflow(String),
#[error("{}", translate!("dd-error-block-without-cbs"))]
BlockUnblockWithoutCBS,
#[error("{}", translate!("dd-error-status-not-recognized", "level" => .0.clone()))]
#[error("{}", translate!("dd-error-status-not-recognized", "level" => .0))]
StatusLevelNotRecognized(String),
#[error("{}", translate!("dd-error-unimplemented", "feature" => .0.clone()))]
#[error("{}", translate!("dd-error-unimplemented", "feature" => .0))]
Unimplemented(String),
#[error("{}", translate!("dd-error-bs-out-of-range", "param" => .0.clone()))]
#[error("{}", translate!("dd-error-bs-out-of-range", "param" => .0))]
BsOutOfRange(String),
#[error("{}", translate!("dd-error-invalid-number", "input" => .0.clone()))]
#[error("{}", translate!("dd-error-invalid-number", "input" => .0))]
InvalidNumber(String),
#[error("invalid number: '{0}': {1}")]
InvalidNumberWithErrMsg(String, String),
Expand Down
8 changes: 4 additions & 4 deletions src/uu/df/src/df.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ impl Options {
enum OptionsError {
// TODO This needs to vary based on whether `--block-size`
// or `-B` were provided.
#[error("{}", translate!("df-error-block-size-too-large", "size" => .0.clone()))]
#[error("{}", translate!("df-error-block-size-too-large", "size" => .0))]
BlockSizeTooLarge(String),
// TODO This needs to vary based on whether `--block-size`
// or `-B` were provided.,
#[error("{}", translate!("df-error-invalid-block-size", "size" => .0.clone()))]
#[error("{}", translate!("df-error-invalid-block-size", "size" => .0))]
InvalidBlockSize(String),
// TODO This needs to vary based on whether `--block-size`
// or `-B` were provided.
#[error("{}", translate!("df-error-invalid-suffix", "size" => .0.clone()))]
#[error("{}", translate!("df-error-invalid-suffix", "size" => .0))]
InvalidSuffix(String),

/// An error getting the columns to display in the output table.
Expand Down Expand Up @@ -189,7 +189,7 @@ fn block_size_error(
let message = options_error.to_string();
error.size_value_error(
diag_args,
&OptionValue::new(size.clone(), 'B', OPT_BLOCKSIZE_LONG),
&OptionValue::new(size, 'B', OPT_BLOCKSIZE_LONG),
0,
&message,
DfError::OptionsError(options_error),
Expand Down
2 changes: 1 addition & 1 deletion src/uu/du/src/du.rs
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ fn build_exclude_patterns(matches: &ArgMatches) -> UResult<Vec<Pattern>> {
if matches.get_flag(options::VERBOSE) {
println!(
"{}",
translate!("du-verbose-adding-to-exclude-list", "pattern" => f.clone())
translate!("du-verbose-adding-to-exclude-list", "pattern" => f)
);
}
let glob = parse_glob::from_str(&f).map_err(DuError::InvalidGlob)?;
Expand Down
4 changes: 2 additions & 2 deletions src/uu/env/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ use thiserror::Error;
pub enum EnvError {
#[error("{}", translate!("env-error-missing-closing-quote", "position" => .0, "quote" => .1))]
EnvMissingClosingQuote(usize, char),
#[error("{}", translate!("env-error-invalid-backslash-at-end", "position" => .0, "context" => .1.clone()))]
#[error("{}", translate!("env-error-invalid-backslash-at-end", "position" => .0, "context" => .1))]
EnvInvalidBackslashAtEndOfStringInMinusS(usize, String),
#[error("{}", translate!("env-error-backslash-c-not-allowed", "position" => .0))]
EnvBackslashCNotAllowedInDoubleQuotes(usize),
Expand All @@ -71,7 +71,7 @@ pub enum EnvError {
EnvParsingOfMissingVariable(usize),
#[error("{}", translate!("env-error-only-braced-variable", "position" => .0))]
EnvParsingOfVariableOnlyBracedName(usize),
#[error("{}", translate!("env-error-unexpected-number", "position" => .0, "char" => .1.clone()))]
#[error("{}", translate!("env-error-unexpected-number", "position" => .0, "char" => .1))]
EnvParsingOfVariableUnexpectedNumber(usize, String),
#[error("")]
EnvReachedEnd,
Expand Down
22 changes: 9 additions & 13 deletions src/uu/install/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ enum InstallError {
#[error("{}", translate!("install-error-chmod-failed", "path" => .0.quote()))]
ChmodFailed(PathBuf),

#[error("{}", translate!("install-error-chown-failed", "path" => .0.quote(), "error" => .1.clone()))]
#[error("{}", translate!("install-error-chown-failed", "path" => .0.quote(), "error" => .1))]
ChownFailed(PathBuf, String),

#[error("{}", translate!("install-error-invalid-target", "path" => .0.quote()))]
Expand All @@ -92,10 +92,10 @@ enum InstallError {
#[error("{}", translate!("install-error-backing-up-destroy-source", "dest" => .0.quote(), "source" => .1.quote()))]
BackupWouldDestroySource(PathBuf, PathBuf),

#[error("{}", translate!("install-error-install-failed", "from" => .0.quote(), "to" => .1.quote(), "error" => .2.clone()))]
#[error("{}", translate!("install-error-install-failed", "from" => .0.quote(), "to" => .1.quote(), "error" => .2))]
InstallFailed(PathBuf, PathBuf, String),

#[error("{}", translate!("install-error-strip-failed", "error" => .0.clone()))]
#[error("{}", translate!("install-error-strip-failed", "error" => .0))]
StripProgramFailed(String),

#[error("{}", translate!("install-error-strip-terminated"))]
Expand Down Expand Up @@ -125,7 +125,7 @@ enum InstallError {
#[error("{}", translate!("install-error-same-file", "file1" => .0.quote(), "file2" => .1.quote()))]
SameFile(PathBuf, PathBuf),

#[error("{}", translate!("install-error-extra-operand", "operand" => .0.quote(), "usage" => .1.clone()))]
#[error("{}", translate!("install-error-extra-operand", "operand" => .0.quote(), "usage" => .1))]
ExtraOperand(OsString, String),

#[cfg(all(feature = "selinux", any(target_os = "linux", target_os = "android")))]
Expand Down Expand Up @@ -655,7 +655,7 @@ fn standard(mut paths: Vec<OsString>, b: &Behavior) -> UResult<()> {

// If -t is used, check if target exists as a file before trying to create directories
if b.target_dir.is_some() && target.exists() && !target.is_dir() {
return Err(InstallError::NotADirectory(target.clone()).into());
return Err(InstallError::NotADirectory(target).into());
}

if let Some(to_create) = to_create {
Expand Down Expand Up @@ -765,9 +765,7 @@ fn standard(mut paths: Vec<OsString>, b: &Behavior) -> UResult<()> {
}

if b.no_target_dir && target.is_dir() {
return Err(
InstallError::OverrideDirectoryFailed(target.clone(), source.clone()).into(),
);
return Err(InstallError::OverrideDirectoryFailed(target, source.clone()).into());
}

if is_potential_directory_path(&target) {
Expand Down Expand Up @@ -993,11 +991,9 @@ fn copy_file(from: &Path, to: &Path) -> UResult<()> {
}

if to.is_dir() && !from.is_dir() {
return Err(InstallError::OverrideDirectoryFailed(
to.to_path_buf().clone(),
from.to_path_buf().clone(),
)
.into());
return Err(
InstallError::OverrideDirectoryFailed(to.to_path_buf(), from.to_path_buf()).into(),
);
}

// Remove existing file (create_new below provides TOCTOU protection)
Expand Down
2 changes: 1 addition & 1 deletion src/uu/join/src/join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ fn parse_settings(matches: &clap::ArgMatches, diag_args: Option<&[OsString]>) ->
continue;
}
// `-o` has no long form.
let option = OptionValue::with_names(format.clone(), Some('o'), None);
let option = OptionValue::with_names(format, Some('o'), None);
// Each field carries its place in the value, so that the caret can
// take the one that is at fault out of a long list.
for (part, span) in uucore::diagnostics::list_items(format, &[' ', ',', '\t']) {
Expand Down
4 changes: 2 additions & 2 deletions src/uu/ln/src/ln.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub enum LnError {
#[error("{}", translate!("ln-error-missing-destination", "operand" => _0.quote()))]
MissingDestination(PathBuf),

#[error("{}", translate!("ln-error-extra-operand", "operand" => _0.quote(), "program" => _1.clone()))]
#[error("{}", translate!("ln-error-extra-operand", "operand" => _0.quote(), "program" => _1))]
ExtraOperand(OsString, String),

#[error("{}", translate!("ln-failed-to-create-hard-link-dir", "source" => _0.to_string_lossy()))]
Expand Down Expand Up @@ -350,7 +350,7 @@ fn link_files_in_dir(files: &[PathBuf], target_dir: &Path, settings: &Settings)
all_successful = false;
}

linked_destinations.insert(targetpath.clone());
linked_destinations.insert(targetpath);
}
if all_successful {
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/uu/ls/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ fn extract_quoting_style(
let _ = writeln!(
io::stderr(),
"{}",
translate!("ls-invalid-quoting-style", "program" => std::env::args().next().unwrap_or_else(|| "ls".to_string()), "style" => style.clone())
translate!("ls-invalid-quoting-style", "program" => std::env::args().next().unwrap_or_else(|| "ls".to_string()), "style" => style)
);
}

Expand Down
12 changes: 5 additions & 7 deletions src/uu/mktemp/src/mktemp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ enum MkTempError {
#[error("{}", translate!("mktemp-error-too-many-templates"))]
TooManyTemplates,

#[error("{}", translate!("mktemp-error-not-found", "template_type" => .0.clone(), "template" => .1.quote()))]
#[error("{}", translate!("mktemp-error-not-found", "template_type" => .0, "template" => .1.quote()))]
NotFound(String, PathBuf),
}

Expand Down Expand Up @@ -237,7 +237,7 @@ impl Params {

// The template argument must end in 'X' if a suffix option is given.
if options.suffix.is_some() && !template_str.ends_with('X') {
return Err(MkTempError::MustEndInX(template_str.clone()));
return Err(MkTempError::MustEndInX(template_str));
}

// Get the start and end indices of the randomized part of the template.
Expand All @@ -250,7 +250,7 @@ impl Params {
.chars()
.take(template_str.len())
.collect::<String>(),
None => template_str.clone(),
None => template_str,
};
return Err(MkTempError::TooFewXs(s));
};
Expand All @@ -264,12 +264,10 @@ impl Params {
let prefix_from_template = &template_str[..i];
let prefix_path = Path::new(&prefix_from_option).join(prefix_from_template);
if options.treat_as_template && prefix_from_template.contains(MAIN_SEPARATOR) {
return Err(MkTempError::PrefixContainsDirSeparator(
template_str.clone(),
));
return Err(MkTempError::PrefixContainsDirSeparator(template_str));
}
if tmpdir.is_some() && Path::new(prefix_from_template).is_absolute() {
return Err(MkTempError::InvalidTemplate(template_str.clone().into()));
return Err(MkTempError::InvalidTemplate(template_str.into()));
}

// Split the parent directory from the file part of the prefix.
Expand Down
18 changes: 9 additions & 9 deletions src/uu/mv/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ use uucore::translate;

#[derive(Debug, Error)]
pub enum MvError {
#[error("{}", translate!("mv-error-no-such-file", "path" => .0.clone()))]
#[error("{}", translate!("mv-error-no-such-file", "path" => .0))]
NoSuchFile(String),
#[error("{}", translate!("mv-error-cannot-stat-not-directory", "path" => .0.clone()))]
#[error("{}", translate!("mv-error-cannot-stat-not-directory", "path" => .0))]
CannotStatNotADirectory(String),
#[error("{}", translate!("mv-error-same-file", "source" => .0.clone(), "target" => .1.clone()))]
#[error("{}", translate!("mv-error-same-file", "source" => .0, "target" => .1))]
SameFile(String, String),
#[error("{}", translate!("mv-error-self-target-subdirectory", "source" => .0.clone(), "target" => .1.clone()))]
#[error("{}", translate!("mv-error-self-target-subdirectory", "source" => .0, "target" => .1))]
SelfTargetSubdirectory(String, String),
#[error("{}", translate!("mv-error-directory-to-non-directory", "path" => .0.clone()))]
#[error("{}", translate!("mv-error-directory-to-non-directory", "path" => .0))]
DirectoryToNonDirectory(String),
#[error("{}", translate!("mv-error-non-directory-to-directory", "source" => .0.clone(), "target" => .1.clone()))]
#[error("{}", translate!("mv-error-non-directory-to-directory", "source" => .0, "target" => .1))]
NonDirectoryToDirectory(String, String),
#[error("{}", translate!("mv-error-not-directory", "path" => .0.clone()))]
#[error("{}", translate!("mv-error-not-directory", "path" => .0))]
NotADirectory(String),
#[error("{}", translate!("mv-error-target-not-directory", "path" => .0.clone()))]
#[error("{}", translate!("mv-error-target-not-directory", "path" => .0))]
TargetNotADirectory(String),
#[error("{}", translate!("mv-error-failed-access-not-directory", "path" => .0.clone()))]
#[error("{}", translate!("mv-error-failed-access-not-directory", "path" => .0))]
FailedToAccessNotADirectory(String),
}

Expand Down
4 changes: 2 additions & 2 deletions src/uu/od/src/od.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ fn parse_bytes_option(
Err(e) => {
let message =
format_error_message(&e, s, &option_display_name(args, option_name, short));
let option = OptionValue::with_names(s.clone(), short, Some(option_name));
let option = OptionValue::with_names(s, short, Some(option_name));
Err(e.size_value_error(
diag_args,
&option,
Expand Down Expand Up @@ -162,7 +162,7 @@ impl OdOptions {
1,
translate!(
"od-error-invalid-argument",
"option" => width_display.clone(),
"option" => width_display,
"value" => s.quote()
),
));
Expand Down
9 changes: 4 additions & 5 deletions src/uu/pr/src/pr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@
let n_regex = Regex::new(r"^-n\s*$").unwrap();
// `-e` ends a cluster of short flags that take no value of their own, as in `-tre`.
// Options that do take a value are excluded so that `-se` keeps meaning `-s e`.
let e_regex = Regex::new(r"^-[dtTrFfabmJ]*e$").unwrap();

Check warning on line 435 in src/uu/pr/src/pr.rs

View workflow job for this annotation

GitHub Actions / Style/spelling (ubuntu-latest, feat_os_unix)

WARNING: `cspell`: Unknown word 'Ffabm' (file:'src/uu/pr/src/pr.rs', line:435)
let mut arguments = args.to_owned();
let num_option = args
.iter()
Expand Down Expand Up @@ -1179,7 +1179,7 @@
// TODO Optimization opportunity: don't bother pushing
// lines and pages if we aren't going to display it.
if start_page <= page_num + 1 && end_page.is_none_or(|e| page_num < e) {
pages.push((page_num, page.clone()));
pages.push((page_num, std::mem::take(&mut page)));
}
page_num += 1;
page.clear();
Expand All @@ -1203,7 +1203,7 @@
// and clear the `page` buffer for the next iteration.
if page.len() >= lines_needed_per_page {
if start_page <= page_num + 1 && end_page.is_none_or(|e| page_num < e) {
pages.push((page_num, page.clone()));
pages.push((page_num, std::mem::take(&mut page)));
}
page_num += 1;
page.clear();
Expand All @@ -1219,7 +1219,7 @@

// Consider all trailing lines as the last page.
if !page.is_empty() && start_page <= page_num + 1 && end_page.is_none_or(|e| page_num < e) {
pages.push((page_num, page.clone()));
pages.push((page_num, std::mem::take(&mut page)));
}

(pages, page_num + 1)
Expand Down Expand Up @@ -1249,8 +1249,7 @@
current_group.push(file_line);
}
Some(key) => {
result.push((key, current_group.clone()));
current_group.clear();
result.push((key, std::mem::take(&mut current_group)));
current_key = Some(group_key(num_files, &file_line));
current_group.push(file_line);
}
Expand Down
Loading
Loading