Skip to content

Command context is not properly passed on to sub-commands #1109

@lewisparma

Description

@lewisparma

When using 'ExecuteContext' on the parent command, the context is not properly passed on to sub commands. It's passed on only the first time, then on the following invocations the first passed value is used. The culprit seems to be this section from commands.go:

// We have to pass global context to children command
// if context is present on the parent command.
if cmd.ctx == nil {
cmd.ctx = c.ctx
}

the parent context should always be passed on to the child command, not just when the child context is null.

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage/needs-infoNeeds more investigation from maintainers or more info from the issue provider

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions