Skip to content

include doesn't recognize '~' as home directory #21337

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
m-j-w opened this issue Apr 9, 2017 · 3 comments
Closed

include doesn't recognize '~' as home directory #21337

m-j-w opened this issue Apr 9, 2017 · 3 comments
Labels
won't change Indicates that work won't continue on an issue or pull request

Comments

@m-j-w
Copy link
Contributor

m-j-w commented Apr 9, 2017

On Linux, using today's master, including a file using tilde as first character is not recognized as a file below the user home directory:

julia> include("~/test.jl")
ERROR: could not open file /home/mjw/src/julia-master/~/test.jl
Stacktrace:
 [1] include_from_node1(::String) at ./loading.jl:539
 [2] include(::String) at ./sysimg.jl:14
julia> pwd()
"/home/mjw/src/julia-master"
@m-j-w
Copy link
Contributor Author

m-j-w commented Apr 9, 2017

A possible fix might be to add expanduser to https://github.com/JuliaLang/julia/blob/master/base/sysimg.jl#L7-L17 where not in the first include state:

function include(path::AbstractString)
    local result
    if INCLUDE_STATE === 1
        result = Core.include(path)
    elseif INCLUDE_STATE === 2
        result = _include(expanduser(path))
    elseif INCLUDE_STATE === 3
        result = include_from_node1(expanduser(path))
    end
    result
end

giving

julia> include("~/test.jl")
ERROR: could not open file /home/mjw/test.jl
Stacktrace:
 [1] include_from_node1(::String) at ./loading.jl:539
 [2] include(::String) at ./sysimg.jl:14

If this is indeed a feasible fix I could make a PR.

@yuyichao
Copy link
Contributor

yuyichao commented Apr 9, 2017

No functions implicitly treat ~ as home directory. Doing that for low level functions will cause many unwanted corner cases.

@yuyichao yuyichao closed this as completed Apr 9, 2017
@yuyichao yuyichao added the won't change Indicates that work won't continue on an issue or pull request label Apr 9, 2017
@yuyichao
Copy link
Contributor

yuyichao commented Apr 9, 2017

Ref #1136. AFAICT this is a shell thing so doing that in shell mode/command literal might make sense but doing it for other low level interfaces doesn't make sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
won't change Indicates that work won't continue on an issue or pull request
Projects
None yet
Development

No branches or pull requests

2 participants