Skip to content

Commit 1e78c64

Browse files
committed
make REPL completions robust against expanduser throwing (#47058)
(cherry picked from commit 7beeaf7)
1 parent 4da1a66 commit 1e78c64

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
@@ -312,7 +312,12 @@ function complete_path(path::AbstractString, pos::Int; use_envpath=false, shell_
312312
end
313313

314314
function complete_expanduser(path::AbstractString, r)
315-
expanded = expanduser(path)
315+
expanded =
316+
try expanduser(path)
317+
catch e
318+
e isa ArgumentError || rethrow()
319+
path
320+
end
316321
return Completion[PathCompletion(expanded)], r, path != expanded
317322
end
318323

stdlib/REPL/test/replcompletions.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,9 @@ let s, c, r
953953
s = "\"~"
954954
@test "tmpfoobar/" in c
955955
c,r = test_complete(s)
956+
s = "\"~user"
957+
c, r = test_complete(s)
958+
@test isempty(c)
956959
rm(dir)
957960
end
958961
end

0 commit comments

Comments
 (0)