From 2a02f01fc2ac3b5e86f56543cd6daf396ea70c07 Mon Sep 17 00:00:00 2001 From: Juliana Rodrigueiro Date: Fri, 2 Apr 2021 19:13:56 +0100 Subject: [PATCH] install: Don't display success message when the dir was not created Also don't run chmod when we just failed to create the directory. Behaviour before this patch: $ ./target/release/install -v -d dir1/dir2 install: dir1/dir2: Permission denied (os error 13) install: dir1/dir2: chmod failed with error No such file or directory (os error 2) install: created directory 'dir1/dir2' --- src/uu/install/src/install.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/uu/install/src/install.rs b/src/uu/install/src/install.rs index 35097da09..6267ed94f 100644 --- a/src/uu/install/src/install.rs +++ b/src/uu/install/src/install.rs @@ -364,15 +364,17 @@ fn directory(paths: Vec, b: Behavior) -> i32 { if let Err(e) = fs::create_dir(directory) { show_info!("{}: {}", path.display(), e.to_string()); all_successful = false; + continue; + } + + if b.verbose { + show_info!("creating directory '{}'", path.display()); } } if mode::chmod(&path, b.mode()).is_err() { all_successful = false; - } - - if b.verbose { - show_info!("creating directory '{}'", path.display()); + continue; } } if all_successful {