Skip to content

Why does setenv & thus addenv discard the cmd's dir? #42131

Closed
@singularitti

Description

@singularitti

When I run setenv or addenv, I was expecting its dir does not change in this process since the only thing I want to change is ENV. But it turns out dir is cleared after a setenv or an addenv:

julia> Cmd(`ls`; dir = "/usr/local").dir
"/usr/local"

julia> setenv(Cmd(`ls`; dir = "/usr/local")).dir
""

julia> addenv(Cmd(`ls`; dir = "/usr/local")).dir
""

However, I found the flag ignorestatus is inherited:

julia> Cmd(`ls`, dir = "/usr/local/bin", ignorestatus=true).ignorestatus
true

julia> setenv(Cmd(`ls`, dir = "/usr/local/bin", ignorestatus=true), ENV).ignorestatus
true

Should we let dir in setenv & addenv defaults to cmd.dir?

setenv(command::Cmd, env; dir=command.dir)
julia> versioninfo()
Julia Version 1.6.2
Commit 1b93d53fc4 (2021-07-14 15:36 UTC)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions