Skip to content

Commit

Permalink
real_path -> tilde_expand in cd. Also, fix tilde expansion of just pl…
Browse files Browse the repository at this point in the history
…ain "~"
  • Loading branch information
timholy committed Aug 8, 2012
1 parent d3ba546 commit b9441d1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion base/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ function tilde_expand(path::String)
if m != nothing
return ENV["HOME"]*path[2:end]
end
if path == "~"
return ENV["HOME"]
end
path
end

Expand Down Expand Up @@ -181,7 +184,7 @@ function cwd()
cstring(p)
end

cd(dir::String) = system_error("chdir", ccall(:chdir,Int32,(Ptr{Uint8},),real_path(dir)) == -1)
cd(dir::String) = system_error("chdir", ccall(:chdir,Int32,(Ptr{Uint8},),tilde_expand(dir)) == -1)
cd() = cd(ENV["HOME"])

# do stuff in a directory, then return to current directory
Expand Down

0 comments on commit b9441d1

Please sign in to comment.