You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
interp: add BashOpts for shopt options, just like Params for set options #962
interp.New() currently has a field for accepting a set of interp.Params(params...). This allows us to set POSIX options like set -e. However, we are not able to pass Bash opts (like shopt -s pipefail), despite the project supporting them. This leads to us having to manually prepend these commands in Task. See this related issue and PR.
It would be really nice if we has something like interp.BashOpts(opts...) to do this for us.
I've been meaning to open a PR for a while for this, but simply haven't had the time. I'm opening this issue for now in case anyone has more bandwidth to work on this.
You're right that there's an asymmetry here, so we should fix that.
I'm not entirely sure why I called the existing API Params. It can be used to set the arguments per "$@", but it also behaves like set so it allows setting some options. In any case, I think BashOpts is okay.
We should be careful about the behavior of interp.BashOpts(), as shopt without arguments prints all existing options, and we likely don't want that in the constructor. I think it could be a no-op for zero arguments.
changed the title [-]Support Bash ops (shopt) in interp.Runner[/-][+]interp: add BashOpts for shopt options, just like Params for set options[/+]on Jan 7, 2023
Activity
mvdan commentedon Jan 7, 2023
You're right that there's an asymmetry here, so we should fix that.
I'm not entirely sure why I called the existing API
Params. It can be used to set the arguments per"$@", but it also behaves likesetso it allows setting some options. In any case, I thinkBashOptsis okay.We should be careful about the behavior of
interp.BashOpts(), asshoptwithout arguments prints all existing options, and we likely don't want that in the constructor. I think it could be a no-op for zero arguments.[-]Support Bash ops (shopt) in interp.Runner[/-][+]interp: add BashOpts for shopt options, just like Params for set options[/+]interp: add BashOpts to set Bash options like shopt