Fixed command piping

This commit is contained in:
Prozilla 2024-05-04 17:01:29 +02:00
parent 0bd7e8502b
commit 3b5f205b92
No known key found for this signature in database
GPG key ID: 5858DFE71CAF31EE

View file

@ -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);