fix: validate set and shopt options when reading a Taskfile - #2911
fix: validate set and shopt options when reading a Taskfile#2911posidoni wants to merge 1 commit into
Conversation
trulede
left a comment
There was a problem hiding this comment.
IMHO I think it would be better if errors with options were raised by mvdan (which I think does this already, perhaps?) than to have to keep such a list up to date.
End effect would be (is) the same, an error.
|
mvdan does raise an error today, but only at runtime, once per command, after Task has already started executing: every command in the task fails with On keeping the list up to date: fair point, though we already maintain exactly this list in schema.json for editor completion (it had drifted, this PR brings it back in sync). If a second copy in Go feels wrong, I can drop the list entirely and probe the interpreter at parse time instead: run |
trulede
left a comment
There was a problem hiding this comment.
I think its reasonable to update the schema.
However, adding programmatic checks would prevent passing new values to mvdan in the future. As it stands now, you get an error from mvdan ... fix the typo ... and move on.
Follow-up to #2429. The panic from that issue was fixed upstream in
mvdan/sh, but an invalidset:/shopt:option is still only reported when a command actually runs — once per command, with no hint about the actual mistake:This PR validates
setandshoptlists when the Taskfile is read (root, task and command level), following the approach of #2892:posixOptsTable/bashOptsTable(mvdan.cc/sh/v3/interp), i.e. exactly what works at runtime.shopt: ["-o", "pipefail"]keeps working: a-oentry switches validation of the remaining entries tosetoptions, matchingshopt -s -osemantics (covered by a regression test).pipefail→set,globstar→shopt).schema.json: theshoptenum was missing three supported options (dotglob,extglob,nocaseglob) — extended to all six; reference docs updated accordingly.Note on behavior: an invalid option now fails at parse time even if the task declaring it never runs — consistent with other Taskfile validation such as #2892.
Tested with four new tests (an invalid option at each of the three levels, plus the
-oregression) and a fullgo test ./...run.Disclosure per the AI usage policy: this PR (code and description) was prepared with AI assistance. I reviewed and tested all changes and can explain every line.