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