mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +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() {
|
||||
for path in matches.free.iter() {
|
||||
let p = Path::new(path);
|
||||
let d = p.parent().unwrap().to_str();
|
||||
if d.is_some() {
|
||||
print!("{}", d.unwrap());
|
||||
match p.parent() {
|
||||
Some(d) => {
|
||||
if d.components().next() == None {
|
||||
print!(".")
|
||||
} else {
|
||||
print!("{}", d.to_string_lossy());
|
||||
}
|
||||
}
|
||||
None => {
|
||||
if p.is_absolute() {
|
||||
print!("/");
|
||||
} else {
|
||||
print!(".");
|
||||
}
|
||||
}
|
||||
}
|
||||
print!("{}", separator);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue