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

touch/gnu compat: 'touch no-file' exit code should be 1

This commit is contained in:
Sylvestre Ledru 2021-06-02 23:43:16 +02:00
parent eb2c06c37e
commit 31875a241f
2 changed files with 8 additions and 0 deletions

View file

@ -168,6 +168,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
if let Err(e) = File::create(path) { if let Err(e) = File::create(path) {
show_warning!("cannot touch '{}': {}", path, e); show_warning!("cannot touch '{}': {}", path, e);
error_code = 1;
continue; continue;
}; };

View file

@ -459,3 +459,10 @@ fn test_touch_system_fails() {
.fails() .fails()
.stderr_contains("setting times of '/'"); .stderr_contains("setting times of '/'");
} }
#[test]
fn test_touch_trailing_slash() {
let (_at, mut ucmd) = at_and_ucmd!();
let file = "no-file/";
ucmd.args(&[file]).fails();
}