-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Conversation
base/path.jl
Outdated
elseif path == "/" | ||
return "/" | ||
elseif path == "~" | ||
return basename(ENV["HOME"]) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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 ~
There was a problem hiding this comment.
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 '~'
.
On Windows this will need to work with |
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. |
closed by #37580 |
fixes #33000
The current implementation of
basename
isn't consistent to POSIX basenamecc: @rfourquet @sjoelund