[rtems-source-builder commit] sb/config: Expanded nested shell commands

Chris Johns chrisj at rtems.org
Tue Mar 3 02:01:22 UTC 2020


Module:    rtems-source-builder
Branch:    master
Commit:    175ce0bcb0618c22d67735f4c83b0ab140a1f609
Changeset: http://git.rtems.org/rtems-source-builder/commit/?id=175ce0bcb0618c22d67735f4c83b0ab140a1f609

Author:    Chris Johns <chrisj at rtems.org>
Date:      Mon Mar  2 14:45:29 2020 +1100

sb/config: Expanded nested shell commands

Updates #3893

---

 source-builder/sb/config.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/source-builder/sb/config.py b/source-builder/sb/config.py
index d4c58aa..e781b8e 100644
--- a/source-builder/sb/config.py
+++ b/source-builder/sb/config.py
@@ -419,7 +419,7 @@ class file:
             print('-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=')
         return macros
 
-    def _shell(self, line):
+    def _shell(self, line, nesting = 0):
         #
         # Parse the line and handle nesting '()' pairs. If on Windows
         # handle embedded '"' (double quotes) as the command is run as
@@ -442,6 +442,9 @@ class file:
                                                                             output))
             return output
 
+        if nesting > 200:
+            raise error.general('shell macro failed: too many nesting levels')
+
         updating = True
         while updating:
             updating = False
@@ -455,9 +458,11 @@ class file:
                         if braces > 0:
                             braces -= 1
                         else:
-                            line = line[:pos] + _exec(line[pos:p + 1]) + line[p + 1:]
+                            shell_cmd = '%(' + self._shell(line[pos + 2:p], nesting + 1) + ')'
+                            line = line[:pos] + _exec(shell_cmd) + line[p + 1:]
                             updating = True
                             break
+
         return line
 
     def _pkgconfig_check(self, test):



More information about the vc mailing list