You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2021/02/04 07:10:22 UTC

[buildstream] 05/06: buildelement.py: Strip the commands fed to the shell

This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch tristan/stop-stripping-whitespace
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 73cfbe52f2ba82e83383dc5d81de5042516ae5ac
Author: Tristan Van Berkom <tr...@codethink.co.uk>
AuthorDate: Tue Dec 11 20:55:58 2018 +0900

    buildelement.py: Strip the commands fed to the shell
    
    Otherwise the formatting of variables can result in multiple
    newlines fed to the shell command, which breaks builds.
---
 buildstream/buildelement.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/buildstream/buildelement.py b/buildstream/buildelement.py
index 06c6235..5eb4391 100644
--- a/buildstream/buildelement.py
+++ b/buildstream/buildelement.py
@@ -293,6 +293,13 @@ class BuildElement(Element):
         return commands
 
     def __run_command(self, sandbox, cmd, cmd_name):
+
+        # Because of variable expansion, sometimes the command
+        # may have trailing whitespace or newlines, strip this
+        # out and ensure we feed a sanitized string to the shell.
+        #
+        cmd = cmd.strip()
+
         # Note the -e switch to 'sh' means to exit with an error
         # if any untested command fails.
         #