Skip to content

Commit 28f7d56

Browse files
authored
Merge pull request #6146 from sylvestre/mktemp
mktemp: adjust the error message to match 9.5
2 parents 20a5e96 + ee19812 commit 28f7d56

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/uu/mktemp/src/mktemp.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,13 @@ impl Params {
236236
let (i, j) = match find_last_contiguous_block_of_xs(&options.template) {
237237
None => {
238238
let s = match options.suffix {
239+
// If a suffix is specified, the error message includes the template without the suffix.
240+
Some(_) => options
241+
.template
242+
.chars()
243+
.take(options.template.len())
244+
.collect::<String>(),
239245
None => options.template,
240-
Some(s) => format!("{}{}", options.template, s),
241246
};
242247
return Err(MkTempError::TooFewXs(s));
243248
}

tests/by-util/test_mktemp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,15 +629,15 @@ fn test_too_few_xs_suffix() {
629629
new_ucmd!()
630630
.args(&["--suffix=X", "aXX"])
631631
.fails()
632-
.stderr_only("mktemp: too few X's in template 'aXXX'\n");
632+
.stderr_only("mktemp: too few X's in template 'aXX'\n");
633633
}
634634

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

643643
#[test]

0 commit comments

Comments
 (0)