1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 19:47:45 +00:00

dirname: fix "/" "." ""

This commit is contained in:
Michael Gehring 2015-12-21 11:14:08 +01:00
parent 7c1bb4cb97
commit c918fb6a6b

View file

@ -54,9 +54,21 @@ directory).", NAME, VERSION);
if !matches.free.is_empty() { if !matches.free.is_empty() {
for path in matches.free.iter() { for path in matches.free.iter() {
let p = Path::new(path); let p = Path::new(path);
let d = p.parent().unwrap().to_str(); match p.parent() {
if d.is_some() { Some(d) => {
print!("{}", d.unwrap()); if d.components().next() == None {
print!(".")
} else {
print!("{}", d.to_string_lossy());
}
}
None => {
if p.is_absolute() {
print!("/");
} else {
print!(".");
}
}
} }
print!("{}", separator); print!("{}", separator);
} }