1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

mktemp: fix error msg when suffix has path sep.

Correct the error message when the template argument contains a path
separator in its suffix. Before this commit:

    $ mktemp aXXX/b
    mktemp: too few X's in template 'b'

After this commit:

    $ mktemp aXXX/b
    mktemp: invalid suffix '/b', contains directory separator

This error message is more appropriate and matches the behavior of GNU
mktemp.
This commit is contained in:
Jeffrey Finkelstein 2022-05-18 18:33:53 -04:00 committed by Sylvestre Ledru
parent 0638e285f1
commit 6260333415
2 changed files with 29 additions and 1 deletions

View file

@ -496,3 +496,18 @@ fn test_template_path_separator() {
"a/bXXX".quote()
));
}
/// Test that a suffix with a path separator is invalid.
#[test]
fn test_suffix_path_separator() {
#[cfg(not(windows))]
new_ucmd!()
.arg("aXXX/b")
.fails()
.stderr_only("mktemp: invalid suffix '/b', contains directory separator\n");
#[cfg(windows)]
new_ucmd!()
.arg(r"aXXX\b")
.fails()
.stderr_only("mktemp: invalid suffix '\\b', contains directory separator\n");
}