From 66408f3929e620842e4ac6845ae78cfb35f06048 Mon Sep 17 00:00:00 2001 From: Jerry Ling Date: Tue, 4 Jun 2019 04:56:26 -0700 Subject: [PATCH] Call expanduser on --project argument, fixes #28638 (#31932) --- base/initdefs.jl | 2 +- src/init.c | 5 ----- test/cmdlineargs.jl | 7 +++++++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/base/initdefs.jl b/base/initdefs.jl index 479f3bd4479d2..be6cf5a409aae 100644 --- a/base/initdefs.jl +++ b/base/initdefs.jl @@ -217,7 +217,7 @@ function init_load_path() HOME_PROJECT[] = project === nothing ? nothing : project == "" ? nothing : - project == "@." ? current_project() : abspath(project) + project == "@." ? current_project() : abspath(expanduser(project)) append!(empty!(LOAD_PATH), paths) end diff --git a/src/init.c b/src/init.c index 5e01d62ae75e7..1c0f6564e5ff4 100644 --- a/src/init.c +++ b/src/init.c @@ -628,11 +628,6 @@ static void jl_resolve_sysimg_location(JL_IMAGE_SEARCH rel) jl_options.outputbc = abspath(jl_options.outputbc, 0); if (jl_options.machine_file) jl_options.machine_file = abspath(jl_options.machine_file, 0); - if (jl_options.project - && strcmp(jl_options.project, "@.") != 0 - && strcmp(jl_options.project, "@") != 0 - && strcmp(jl_options.project, "") != 0) - jl_options.project = abspath(jl_options.project, 0); if (jl_options.output_code_coverage) jl_options.output_code_coverage = absformat(jl_options.output_code_coverage); diff --git a/test/cmdlineargs.jl b/test/cmdlineargs.jl index 92b72955451fd..74d98c2511ad5 100644 --- a/test/cmdlineargs.jl +++ b/test/cmdlineargs.jl @@ -97,6 +97,13 @@ let exename = `$(Base.julia_cmd()) --startup-file=no` @test startswith(read(`$exename --help`, String), header) end + # ~ expansion in --project and JULIA_PROJECT + if !Sys.iswindows() + expanded = abspath(expanduser("~/foo")) + @test occursin(expanded, readchomp(`$exename --project='~/foo' -E 'Base.active_project()'`)) + @test occursin(expanded, readchomp(setenv(`$exename -E 'Base.active_project()'`, "JULIA_PROJECT"=>"~/foo"))) + end + # --quiet, --banner let t(q,b) = "Base.JLOptions().quiet == $q && Base.JLOptions().banner == $b" @test success(`$exename -e $(t(0, -1))`)