Fixed command piping
This commit is contained in:
parent
0bd7e8502b
commit
3b5f205b92
1 changed files with 6 additions and 4 deletions
|
|
@ -208,19 +208,21 @@ export function Terminal({ startPath, input, setTitle, close: exit, active }) {
|
||||||
setHistoryIndex(0);
|
setHistoryIndex(0);
|
||||||
|
|
||||||
// Piping is used to chain commands
|
// Piping is used to chain commands
|
||||||
const pipes = value.split(" | ");
|
let pipes = value.split(" | ");
|
||||||
|
const completedPipes = [];
|
||||||
|
|
||||||
let output = null;
|
let output = null;
|
||||||
pipes.forEach((pipe, index) => {
|
pipes.forEach((pipe) => {
|
||||||
removeFromArray(pipe[index - 1], pipes);
|
|
||||||
|
|
||||||
if (output instanceof Stream)
|
if (output instanceof Stream)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Output from the previous command gets added as an argument for the next command
|
// Output from the previous command gets added as an argument for the next command
|
||||||
output = handleInput(output ? `${pipe} ${output}` : pipe);
|
output = handleInput(output ? `${pipe} ${output}` : pipe);
|
||||||
|
completedPipes.push(pipe);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
pipes = pipes.filter((pipe) => !completedPipes.includes(pipe));
|
||||||
|
|
||||||
if (output) {
|
if (output) {
|
||||||
if (output instanceof Stream) {
|
if (output instanceof Stream) {
|
||||||
connectStream(output, pipes);
|
connectStream(output, pipes);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue