Skip to content

Commit

Permalink
mktemp: adjust the error message to match 9.5
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvestre committed Mar 29, 2024
1 parent 8ae8de0 commit 1931c10
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/uu/mktemp/src/mktemp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,13 @@ impl Params {
let (i, j) = match find_last_contiguous_block_of_xs(&options.template) {
None => {
let s = match options.suffix {
None => options.template,
Some(s) => format!("{}{}", options.template, s),
// If a suffix is specified, the error message includes the template without the suffix.
Some(_) => options
.template
.chars()
.take(options.template.len())
.collect::<String>(),
None => options.template.clone(),
};
return Err(MkTempError::TooFewXs(s));
}
Expand Down
4 changes: 2 additions & 2 deletions tests/by-util/test_mktemp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,15 +629,15 @@ fn test_too_few_xs_suffix() {
new_ucmd!()
.args(&["--suffix=X", "aXX"])
.fails()
.stderr_only("mktemp: too few X's in template 'aXXX'\n");
.stderr_only("mktemp: too few X's in template 'aXX'\n");
}

#[test]
fn test_too_few_xs_suffix_directory() {
new_ucmd!()
.args(&["-d", "--suffix=X", "aXX"])
.fails()
.stderr_only("mktemp: too few X's in template 'aXXX'\n");
.stderr_only("mktemp: too few X's in template 'aXX'\n");
}

#[test]
Expand Down

0 comments on commit 1931c10

Please sign in to comment.