Skip to content

Commit 85b7b56

Browse files
authored
Build: allow multi-line commands on build.commands (#10334)
* Build: allow multi-line commands on `build.commands` This is another attempt to fix this issue. It follows the suggestion posted by @bensze01 in #10103. It looks simple and I think it makes sense to give it a try since it doesn't seem to be harmful. I tested it locally with the branch https://github.com/readthedocs/test-builds/tree/build-commands-multiline and it worked fine. Note that without this PR the branch linked fails. Related #10133 Related #10119 Related #10206 External PRs that should be solved by this one: * pypi/warehouse#12953 * pypi/warehouse#12953 Closes #10103 Closes #10208 * Build: use `;` to separate PREFIX from COMMAND
1 parent 7de4d95 commit 85b7b56

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

readthedocs/doc_builder/environments.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,13 @@ def get_wrapped_command(self):
376376
for part in self.command
377377
)
378378
)
379-
return "/bin/sh -c '{prefix}{cmd}'".format(
380-
prefix=prefix,
381-
cmd=command,
382-
)
379+
if prefix:
380+
# Using `;` or `\n` to separate the `prefix` where we define the
381+
# variables with the `command` itself, have the same effect.
382+
# However, using `;` is more explicit.
383+
# See https://github.com/readthedocs/readthedocs.org/pull/10334
384+
return f"/bin/sh -c '{prefix}; {command}'"
385+
return f"/bin/sh -c '{command}'"
383386

384387
def _escape_command(self, cmd):
385388
r"""Escape the command by prefixing suspicious chars with `\`."""

0 commit comments

Comments
 (0)