Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/uu/ls/src/colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/uu/ls/src/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
),
}
Expand Down Expand Up @@ -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();
Expand Down