From f68ae6df910517113a9e5cdced02691299ce5c36 Mon Sep 17 00:00:00 2001 From: Nathan Fisher Date: Sat, 21 Jan 2023 09:11:54 -0500 Subject: [PATCH] chmod - implement `quiet` --- src/cmd/chmod/mod.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/cmd/chmod/mod.rs b/src/cmd/chmod/mod.rs index a476970..051e5f7 100644 --- a/src/cmd/chmod/mod.rs +++ b/src/cmd/chmod/mod.rs @@ -72,13 +72,20 @@ impl Cmd for Chmod { let action = Action { path, feedback, - quiet: matches.get_flag("quiet"), mode, }; - action.apply()?; + if let Err(e) = action.apply() { + if !matches.get_flag("quiet") { + return Err(e.into()); + } + } if matches.get_flag("recursive") { if action.path.is_dir() { - action.recurse()?; + if let Err(e) = action.recurse() { + if !matches.get_flag("quiet") { + return Err(e.into()); + } + } } } } @@ -94,7 +101,6 @@ impl Cmd for Chmod { struct Action<'a> { path: PathBuf, feedback: Option, - quiet: bool, mode: &'a str, } @@ -151,7 +157,6 @@ impl Action<'_> { Self { path: entry.path().to_path_buf(), feedback: self.feedback, - quiet: self.quiet, mode: self.mode, } }