<div dir="ltr">Sorry, sent the wrong patch, it should be the v2. Ignore this one.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jun 20, 2023 at 12:30 PM Muhammad Sulthan Mazaya <<a href="mailto:msulthanmazaya@gmail.com">msulthanmazaya@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The previous implementation of execute command on rtems-tools config does<br>
not support command line pipe operation. So something like:<br>
<br>
%execute %{command} | %{trim_command}<br>
<br>
Would not work, since the "| %{trim_command}" part is treated as an <br>
additional command option. This patch is intended to fix that issue.<br>
<br>
---<br>
 rtemstoolkit/execute.py | 28 +++++++++++++++++++++++-----<br>
 1 file changed, 23 insertions(+), 5 deletions(-)<br>
<br>
diff --git a/rtemstoolkit/execute.py b/rtemstoolkit/execute.py<br>
index ed81589..9bb7434 100755<br>
--- a/rtemstoolkit/execute.py<br>
+++ b/rtemstoolkit/execute.py<br>
@@ -389,11 +389,29 @@ class execute(object):<br>
                     r, e = os.path.splitext(command[0])<br>
                     if e not in ['.exe', '.com', '.bat']:<br>
                         command[0] = command[0] + '.exe'<br>
-            proc = subprocess.Popen(command, shell = shell,<br>
-                                    cwd = cwd, env = env,<br>
-                                    stdin = stdin, stdout = stdout,<br>
-                                    stderr = stderr,<br>
-                                    close_fds = False)<br>
+                        <br>
+            pipe_commands = []<br>
+            current_command = []<br>
+            for cmd in command:<br>
+                if cmd == '|':<br>
+                    pipe_commands.append(current_command)<br>
+                    current_command = []<br>
+                else:<br>
+                    current_command.append(cmd)<br>
+            pipe_commands.append(current_command)<br>
+<br>
+            proc = None<br>
+            for i, cmd in enumerate(pipe_commands):<br>
+                if i == 0:<br>
+                    proc = subprocess.Popen(<br>
+                        cmd, shell=shell, cwd=cwd, env=env, stdin=stdin, stdout=subprocess.PIPE)<br>
+                elif i == len(pipe_commands) - 1:<br>
+                    proc = subprocess.Popen(<br>
+                        cmd, shell=shell, cwd=cwd, env=env, stdin=proc.stdout, stdout=stdout, stderr=stderr, close_fds=False)<br>
+                else:<br>
+                    proc = subprocess.Popen(<br>
+                        cmd, shell=shell, cwd=cwd, env=env, stdin=proc.stdout, stdout=subprocess.PIPE)<br>
+<br>
             if not capture:<br>
                 return (0, proc)<br>
             if self.output is None:<br>
-- <br>
2.34.1<br>
<br>
</blockquote></div>