Skip to content

Improve shopt integration with mvdan/sh #984

Description

@pd93

We added support for set and shopt in #929. However, the implementation for shopt currently uses a workaround to prepend the shell options to each command before execution:

// Run any shopt commands
if len(opts.BashOpts) > 0 {
shoptCmdStr := fmt.Sprintf("shopt -s %s", strings.Join(opts.BashOpts, " "))
shoptCmd, err := parser.Parse(strings.NewReader(shoptCmdStr), "")
if err != nil {
return err
}
if err := r.Run(ctx, shoptCmd); err != nil {
return err
}
}

Ideally, we would pass Bash options using a new functional option interp.BashOpts and pass this into interp.New() like we do with set params.

mvdan/sh#962 tracks the upstream changes required to complete this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    dep: mvdan/shIssues related to the upstream interpreter used by Task.

    Fields

    No fields configured for feature.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions