Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 1 addition & 2 deletions src/uu/chown/src/chown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ pub fn uu_app() -> Command {
.long(options::REFERENCE)
.help(translate!("chown-help-reference"))
.value_name("RFILE")
.value_hint(clap::ValueHint::FilePath)
.num_args(1..),
.value_hint(clap::ValueHint::FilePath),
)
.arg(
Arg::new(options::verbosity::SILENT)
Expand Down
16 changes: 8 additions & 8 deletions src/uucore/src/lib/mods/clap_localization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub fn handle_clap_error_with_exit_code(err: Error, util_name: &str, exit_code:
let usage_label = translate!("common-usage");
let localized_help = help_text.replace("Usage:", &format!("{usage_label}:"));

print!("{}", localized_help);
print!("{localized_help}");
std::process::exit(0);
}
ErrorKind::DisplayVersion => {
Expand Down Expand Up @@ -174,7 +174,7 @@ pub fn handle_clap_error_with_exit_code(err: Error, util_name: &str, exit_code:
// These usually start with " tip:" and contain useful information
for line in _lines.iter() {
if line.trim().starts_with("tip:") && !line.contains("similar argument") {
eprintln!("{}", line);
eprintln!("{line}");
eprintln!();
}
}
Expand All @@ -185,7 +185,7 @@ pub fn handle_clap_error_with_exit_code(err: Error, util_name: &str, exit_code:
let usage_text = translate!(&usage_key);
let formatted_usage = crate::format_usage(&usage_text);
let usage_label = translate!("common-usage");
eprintln!("{}: {}", usage_label, formatted_usage);
eprintln!("{usage_label}: {formatted_usage}");
eprintln!();
eprintln!("{}", translate!("common-help-suggestion"));

Expand Down Expand Up @@ -243,7 +243,7 @@ pub fn handle_clap_error_with_exit_code(err: Error, util_name: &str, exit_code:
if matches!(kind, ErrorKind::ValueValidation) {
if let Some(source) = err.source() {
// Print error with validation detail on same line
eprintln!("{error_msg}: {}", source);
eprintln!("{error_msg}: {source}");
} else {
// Print localized error message
eprintln!("{error_msg}");
Expand All @@ -262,7 +262,7 @@ pub fn handle_clap_error_with_exit_code(err: Error, util_name: &str, exit_code:
if let Some(valid_values) = err.get(ContextKind::ValidValue) {
eprintln!();
let possible_values_label = translate!("clap-error-possible-values");
eprintln!(" [{}: {}]", possible_values_label, valid_values);
eprintln!(" [{possible_values_label}: {valid_values}]");
}
}

Expand All @@ -273,7 +273,7 @@ pub fn handle_clap_error_with_exit_code(err: Error, util_name: &str, exit_code:
// Fallback if we can't extract context - use clap's default formatting
let lines: Vec<&str> = rendered_str.lines().collect();
if let Some(main_error_line) = lines.first() {
eprintln!("{}", main_error_line);
eprintln!("{main_error_line}");
eprintln!();
eprintln!("{}", translate!("common-help-suggestion"));
} else {
Expand All @@ -287,7 +287,7 @@ pub fn handle_clap_error_with_exit_code(err: Error, util_name: &str, exit_code:
let lines: Vec<&str> = rendered_str.lines().collect();
if let Some(main_error_line) = lines.first() {
// Keep the "error: " prefix for test compatibility
eprintln!("{}", main_error_line);
eprintln!("{main_error_line}");
eprintln!();
// Use the execution phrase for the help suggestion to match test expectations
eprintln!("{}", translate!("common-help-suggestion"));
Expand Down Expand Up @@ -327,7 +327,7 @@ pub fn handle_clap_error_with_exit_code(err: Error, util_name: &str, exit_code:

// Print error message (first line)
if let Some(first_line) = lines.first() {
eprintln!("{}", first_line);
eprintln!("{first_line}");
}

// For other errors, just show help suggestion
Expand Down
15 changes: 14 additions & 1 deletion tests/by-util/test_chown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

#[cfg(any(target_os = "linux", target_os = "android"))]
use uucore::process::geteuid;
use uutests::new_ucmd;
use uutests::util::{CmdResult, TestScenario, is_ci, run_ucmd_as_root};
use uutests::util_name;
use uutests::{at_and_ucmd, new_ucmd};
// Apparently some CI environments have configuration issues, e.g. with 'whoami' and 'id'.
// If we are running inside the CI and "needle" is in "stderr" skipping this test is
// considered okay. If we are not inside the CI this calls assert!(result.success).
Expand Down Expand Up @@ -844,3 +844,16 @@ fn test_chown_no_change_to_user_group() {
));
}
}

#[test]
fn test_chown_reference_file() {
let (at, mut ucmd) = at_and_ucmd!();
at.touch("a");
at.touch("b");
ucmd.arg("--reference")
.arg("a")
.arg("b")
.succeeds()
.no_stderr()
.no_stdout();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also verify the actual permissions on the file (to make sure it worked properly)
thanks

}
Loading