feat(tasks): support multi-line tasks#5957
Conversation
Join lines of a multi-line task script with `&&` before handing the command off to `deno_task_shell`, which otherwise collapses newlines to whitespace. Execution now stops on the first failing command. Fixes #5937
The previous multi-line join split every newline, including those inside single- or double-quoted arguments. That broke tasks like `python -c "..."` whose quoted body legitimately spans lines. Replace the simple `lines()`/join with a quote-aware walker that only treats newlines outside quotes as command separators. Backslash line continuations are still merged.
|
While the current behavior was a little surprising at first, I think most folk have adapted and likey rely on it, One place where the "newlines become whitespace" is useful is to shell out to some workspace-managed executor, especially with cmd = """python -c "import stuff; [
stuff.do(),
stuff.do_another('''{{ some_arg}}''')
]" """Anyhow, as-is, this behavior will be a fairly brutal breaking change. Perhaps it could be opt-in, initially, or at least be opted out of at the |
|
If I implemented this correctly, the example you gave should not change, except that the newlines become whitespaces. I make sure to break up newlines only when not inside a ' or ". |
|
Sure, I see the caveat about the python case right in the comment; my concern is just that |
…ility pixi 0.68.0 (released 2026-05-08) changes how multi-line task cmds are parsed. Per pixi PR prefix-dev/pixi#5957, bare newlines that were previously joined as whitespace are now joined with '&&', so cmd = '''cmake -Bbuild -S. ...''' is no longer executed as 'cmake -Bbuild -S. ...' but as 'cmake && -Bbuild && -S. && ...'. cmake then runs with no arguments and prints its Usage banner; the next line tries to execute '-Bbuild' as a command and fails with 'command not found'; the task exits 127. Backslash line continuations preserve the legacy single-command behavior on both pre- and post-0.68 pixi versions. Affected tasks (all multi-line cmake invocations under [tool.pixi.feature.cxx.tasks]): configure configure-ci configure-debug configure-release configure-python configure-debug-python The two python-exe tasks already terminate the first line with '&&' so they are not double-separated by 0.68's logic and need no modification. Fixes the global ITK CI Pixi-Cxx breakage observed across all open PRs since pixi 0.68.0 became the default in prefix-dev/setup-pixi.
|
and lo, this did indeed ruin my day (and at least |
Description
deno_task_shellcollapses bare newlines to whitespace, so a multi-line TOML task likewas executed as
echo hello echo hello2, printinghello echo hello2.The fix joins non-empty, non-comment lines with
&&before parsing, so each line runs as a separate command and execution stops on the first failure. Backslash line continuations are merged, and lines already ending in a shell control operator (&&,||,|,;,&) aren't double-separated.Fixes #5937
How Has This Been Tested?
test_as_script_multilineandtest_as_script_multiline_preserves_existing_operatorincrates/pixi_task/src/executable_task.rs.falseline aborts the task with exit code 1 and the subsequent line is not run.AI Disclosure
Tools: Claude (Claude Code)
Checklist:
Generated by Claude Code