diff --git a/NEWS.md b/NEWS.md index fc3a2304ea72ae..54e3d3f63fff21 100644 --- a/NEWS.md +++ b/NEWS.md @@ -68,6 +68,7 @@ difference between defining a `main` function and executing the code directly at * The `--compiled-modules` and `--pkgimages` flags can now be set to `existing`, which will cause Julia to consider loading existing cache files, but not to create new ones ([#50586] and [#52573]). +* The `--project` argument now accepts `@script` to give a path to a directory with a Project.toml relative to the passed script file. E.g. `--project=@script` for the same directory or `--project=@script/foo` for the `foo` subdirectory. ([#50864] and [#53352]) Multi-threading changes ----------------------- diff --git a/base/initdefs.jl b/base/initdefs.jl index 56c2c0c5872728..e37bac9f4b8227 100644 --- a/base/initdefs.jl +++ b/base/initdefs.jl @@ -272,7 +272,7 @@ function load_path_expand(env::AbstractString)::Union{String, Nothing} env == "@" && return active_project(false) env == "@." && return current_project() env == "@stdlib" && return Sys.STDLIB - if startswith(env, "@scriptdir") + if startswith(env, "@script") if @isdefined(PROGRAM_FILE) dir = dirname(PROGRAM_FILE) else @@ -283,7 +283,7 @@ function load_path_expand(env::AbstractString)::Union{String, Nothing} end dir = dirname(ARGS[1]) end - return abspath(replace(env, "@scriptdir" => dir)) + return abspath(replace(env, :wq"@script" => dir)) end env = replace(env, '#' => VERSION.major, count=1) env = replace(env, '#' => VERSION.minor, count=1)