Skip to content

rework basename (fixes #33000) #33021

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

johnnychen94
Copy link
Member

@johnnychen94 johnnychen94 commented Aug 22, 2019

fixes #33000

The current implementation of basename isn't consistent to POSIX basename

cc: @rfourquet @sjoelund

base/path.jl Outdated
elseif path == "/"
return "/"
elseif path == "~"
return basename(ENV["HOME"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

POSIX basename() doesn't do ~ expansion and I don't think ENV["HOME"] will work on Windows. I don't think ~ expansion should be done here.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not to mention ~ is a valid filename...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review, I'm really not very familiar with these rules.

I add this because I checked the basename ~ in Linux and macOS, both returns jc in my case. And basename ~/~ returns ~

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When running basename from the command line it is the shell that is doing the ~ expansion, not the basename utility. Try basename '~'.

@jmkuhn
Copy link
Contributor

jmkuhn commented Aug 22, 2019

On Windows this will need to work with "\\" as a path separator.

@StefanKarpinski StefanKarpinski self-assigned this Aug 22, 2019
@johnnychen94
Copy link
Member Author

johnnychen94 commented Aug 23, 2019

I think this works for Windows now, but I don't have access to a Windows computer these days.

As @musm says, this is a breaking change. I need to get more feedback from others to see if this worth continuing.

@musm
Copy link
Contributor

musm commented Sep 25, 2020

closed by #37580

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

consistent result of basename for dir path
6 participants