Skip to content
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
7 changes: 6 additions & 1 deletion 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 {
// 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,
Some(s) => format!("{}{}", options.template, s),
};
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