From 3b5f205b92502a52f456ffdb8d883384ef7b4d57 Mon Sep 17 00:00:00 2001 From: Prozilla Date: Sat, 4 May 2024 17:01:29 +0200 Subject: [PATCH] Fixed command piping --- src/components/apps/terminal/Terminal.jsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/apps/terminal/Terminal.jsx b/src/components/apps/terminal/Terminal.jsx index 2f1597b..a267e9c 100644 --- a/src/components/apps/terminal/Terminal.jsx +++ b/src/components/apps/terminal/Terminal.jsx @@ -208,19 +208,21 @@ export function Terminal({ startPath, input, setTitle, close: exit, active }) { setHistoryIndex(0); // Piping is used to chain commands - const pipes = value.split(" | "); + let pipes = value.split(" | "); + const completedPipes = []; let output = null; - pipes.forEach((pipe, index) => { - removeFromArray(pipe[index - 1], pipes); - + pipes.forEach((pipe) => { if (output instanceof Stream) return; // Output from the previous command gets added as an argument for the next command output = handleInput(output ? `${pipe} ${output}` : pipe); + completedPipes.push(pipe); }); + pipes = pipes.filter((pipe) => !completedPipes.includes(pipe)); + if (output) { if (output instanceof Stream) { connectStream(output, pipes);