diff --git a/src/uu/ls/src/colors.rs b/src/uu/ls/src/colors.rs index 44ec997ec..6c580d18a 100644 --- a/src/uu/ls/src/colors.rs +++ b/src/uu/ls/src/colors.rs @@ -169,7 +169,7 @@ pub(crate) fn color_name( // Use fn get_metadata_with_deref_opt instead of get_metadata() here because ls // should not exit with an err, if we are unable to obtain the target_metadata let md_res = get_metadata_with_deref_opt(&target.p_buf, path.must_dereference); - let md = md_res.or(path.p_buf.symlink_metadata()); + let md = md_res.or_else(|_| path.p_buf.symlink_metadata()); style_manager.apply_style_based_on_metadata(path, md.ok().as_ref(), name, wrap) } else { let md_option = path.get_metadata(out); diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 582c88c61..238a04bfa 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -697,7 +697,7 @@ fn extract_quoting_style(options: &clap::ArgMatches, show_control: bool) -> Quot Some(qs) => return qs, None => eprintln!( "{}: Ignoring invalid value of environment variable QUOTING_STYLE: '{}'", - std::env::args().next().unwrap_or("ls".to_string()), + std::env::args().next().unwrap_or_else(|| "ls".to_string()), style ), } @@ -3332,7 +3332,7 @@ fn display_item_name( } fn create_hyperlink(name: &str, path: &PathData) -> String { - let hostname = hostname::get().unwrap_or(OsString::from("")); + let hostname = hostname::get().unwrap_or_else(|_| OsString::from("")); let hostname = hostname.to_string_lossy(); let absolute_path = fs::canonicalize(&path.p_buf).unwrap_or_default();