mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
Merge pull request #3117 from jfinkels/touch-no-deref-no-file
touch: show error on -h with nonexistent file
This commit is contained in:
commit
463e160d2f
2 changed files with 25 additions and 2 deletions
|
@ -83,8 +83,18 @@ Try 'touch --help' for more information."##,
|
||||||
for filename in files {
|
for filename in files {
|
||||||
let path = Path::new(filename);
|
let path = Path::new(filename);
|
||||||
if !path.exists() {
|
if !path.exists() {
|
||||||
// no-dereference included here for compatibility
|
if matches.is_present(options::NO_CREATE) {
|
||||||
if matches.is_present(options::NO_CREATE) || matches.is_present(options::NO_DEREF) {
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if matches.is_present(options::NO_DEREF) {
|
||||||
|
show!(USimpleError::new(
|
||||||
|
1,
|
||||||
|
format!(
|
||||||
|
"setting times of {}: No such file or directory",
|
||||||
|
filename.quote()
|
||||||
|
)
|
||||||
|
));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -539,3 +539,16 @@ fn test_touch_no_args() {
|
||||||
Try 'touch --help' for more information."##,
|
Try 'touch --help' for more information."##,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_no_dereference_no_file() {
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["-h", "not-a-file"])
|
||||||
|
.fails()
|
||||||
|
.stderr_contains("setting times of 'not-a-file': No such file or directory");
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["-h", "not-a-file-1", "not-a-file-2"])
|
||||||
|
.fails()
|
||||||
|
.stderr_contains("setting times of 'not-a-file-1': No such file or directory")
|
||||||
|
.stderr_contains("setting times of 'not-a-file-2': No such file or directory");
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue