mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
dirname: fix "/" "." ""
This commit is contained in:
parent
7c1bb4cb97
commit
c918fb6a6b
1 changed files with 15 additions and 3 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue