Skip to content

Commit 7beeaf7

Browse files
authored
make REPL completions robust against expanduser throwing (#47058)
1 parent 7bd8311 commit 7beeaf7

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

stdlib/REPL/src/REPLCompletions.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,12 @@ function complete_path(path::AbstractString, pos::Int; use_envpath=false, shell_
320320
end
321321

322322
function complete_expanduser(path::AbstractString, r)
323-
expanded = expanduser(path)
323+
expanded =
324+
try expanduser(path)
325+
catch e
326+
e isa ArgumentError || rethrow()
327+
path
328+
end
324329
return Completion[PathCompletion(expanded)], r, path != expanded
325330
end
326331

stdlib/REPL/test/replcompletions.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,9 @@ let s, c, r
10991099
s = "\"~"
11001100
@test "tmpfoobar/" in c
11011101
c,r = test_complete(s)
1102+
s = "\"~user"
1103+
c, r = test_complete(s)
1104+
@test isempty(c)
11021105
rm(dir)
11031106
end
11041107
end

0 commit comments

Comments
 (0)