Skip to content

Commit c26ce31

Browse files
committed
make REPL completions robust against expanduser throwing (#47058)
(cherry picked from commit 7beeaf7)
1 parent 89661ac commit c26ce31

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

308308
function complete_expanduser(path::AbstractString, r)
309-
expanded = expanduser(path)
309+
expanded =
310+
try expanduser(path)
311+
catch e
312+
e isa ArgumentError || rethrow()
313+
path
314+
end
310315
return Completion[PathCompletion(expanded)], r, path != expanded
311316
end
312317

stdlib/REPL/test/replcompletions.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,9 @@ let s, c, r
716716
s = "\"~"
717717
@test "tmpfoobar/" in c
718718
c,r = test_complete(s)
719+
s = "\"~user"
720+
c, r = test_complete(s)
721+
@test isempty(c)
719722
rm(dir)
720723
end
721724
end

0 commit comments

Comments
 (0)