From e09b4817e11496a168c4b22abe91db72079a016d Mon Sep 17 00:00:00 2001 From: Stefan Holderbach Date: Sun, 25 Feb 2024 00:02:48 +0100 Subject: [PATCH] Fix future lint by `truncate(false)` in `touch` (#11863) The following clippy lint on nightly would complain: - https://rust-lang.github.io/rust-clippy/master/#/suspicious_open We don't want to alter the content in `touch` or truncate by not writing. While not fully applicable, may be good practice for platforms/filesystems we are not aware of. --- crates/nu-command/src/filesystem/touch.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/nu-command/src/filesystem/touch.rs b/crates/nu-command/src/filesystem/touch.rs index 15c7da865c..095f3e556d 100644 --- a/crates/nu-command/src/filesystem/touch.rs +++ b/crates/nu-command/src/filesystem/touch.rs @@ -136,7 +136,12 @@ impl Command for Touch { } } - if let Err(err) = OpenOptions::new().write(true).create(true).open(&item) { + if let Err(err) = OpenOptions::new() + .write(true) + .create(true) + .truncate(false) + .open(&item) + { return Err(ShellError::CreateNotPossible { msg: format!("Failed to create file: {err}"), span: call