Skip to content

Commit c64adee

Browse files
VenetiaFurtadosylvestrecakebaker
authored
touch: add -f flag (#8274)
* touch: fix f flag * Update src/uu/touch/src/touch.rs Co-authored-by: Sylvestre Ledru <[email protected]> * touch: add test for f flag * Update src/uu/touch/src/touch.rs Co-authored-by: Daniel Hofstetter <[email protected]> * Update tests/by-util/test_touch.rs Co-authored-by: Daniel Hofstetter <[email protected]> * remove unnecessary comment --------- Co-authored-by: Sylvestre Ledru <[email protected]> Co-authored-by: Daniel Hofstetter <[email protected]>
1 parent 1d76a00 commit c64adee

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/uu/touch/src/touch.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ pub mod options {
9999
pub static NO_CREATE: &str = "no-create";
100100
pub static NO_DEREF: &str = "no-dereference";
101101
pub static TIME: &str = "time";
102+
pub static FORCE: &str = "force";
102103
}
103104

104105
static ARG_FILES: &str = "files";
@@ -291,6 +292,13 @@ pub fn uu_app() -> Command {
291292
.value_name("STRING")
292293
.conflicts_with(options::sources::TIMESTAMP),
293294
)
295+
.arg(
296+
Arg::new(options::FORCE)
297+
.short('f')
298+
.help("(ignored)")
299+
.hide(true)
300+
.action(ArgAction::SetTrue),
301+
)
294302
.arg(
295303
Arg::new(options::MODIFICATION)
296304
.short('m')

tests/by-util/test_touch.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,3 +1006,14 @@ fn test_obsolete_posix_format_with_year() {
10061006
assert!(at.file_exists("11111111"));
10071007
assert!(!at.file_exists("0101000090"));
10081008
}
1009+
1010+
#[test]
1011+
fn test_touch_f_option() {
1012+
let (at, mut ucmd) = at_and_ucmd!();
1013+
let file = "test_f_option.txt";
1014+
1015+
ucmd.args(&["-f", file]).succeeds().no_output();
1016+
1017+
assert!(at.file_exists(file));
1018+
at.remove(file);
1019+
}

0 commit comments

Comments
 (0)