Skip to content

Commit b9441d1

Browse files
committed
real_path -> tilde_expand in cd. Also, fix tilde expansion of just plain "~"
1 parent d3ba546 commit b9441d1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

base/file.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ function tilde_expand(path::String)
113113
if m != nothing
114114
return ENV["HOME"]*path[2:end]
115115
end
116+
if path == "~"
117+
return ENV["HOME"]
118+
end
116119
path
117120
end
118121

@@ -181,7 +184,7 @@ function cwd()
181184
cstring(p)
182185
end
183186

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

187190
# do stuff in a directory, then return to current directory

0 commit comments

Comments
 (0)