mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
Merge pull request #8374 from sylvestre/issue-8373
basename: handle a corner case with /. - Closes #8373
This commit is contained in:
@@ -119,6 +119,11 @@ pub fn uu_app() -> Command {
|
||||
}
|
||||
|
||||
fn basename(fullname: &str, suffix: &str) -> String {
|
||||
// Handle special case where path ends with /.
|
||||
if fullname.ends_with("/.") {
|
||||
return ".".to_string();
|
||||
}
|
||||
|
||||
// Convert to path buffer and get last path component
|
||||
let pb = PathBuf::from(fullname);
|
||||
|
||||
|
||||
@@ -183,6 +183,13 @@ fn test_triple_slash() {
|
||||
new_ucmd!().arg("///").succeeds().stdout_is(expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_trailing_dot() {
|
||||
new_ucmd!().arg("/.").succeeds().stdout_is(".\n");
|
||||
new_ucmd!().arg("hello/.").succeeds().stdout_is(".\n");
|
||||
new_ucmd!().arg("/foo/bar/.").succeeds().stdout_is(".\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_simple_format() {
|
||||
new_ucmd!().args(&["a-a", "-a"]).succeeds().stdout_is("a\n");
|
||||
|
||||
Reference in New Issue
Block a user