mirror of
https://github.com/nushell/nushell.git
synced 2025-04-01 11:46:20 +02:00
Let 'each' also send input to block (#5136)
This commit is contained in:
parent
0b85938415
commit
0892a16a3d
@ -2,8 +2,8 @@ use nu_engine::{eval_block, CallExt};
|
|||||||
use nu_protocol::ast::Call;
|
use nu_protocol::ast::Call;
|
||||||
use nu_protocol::engine::{CaptureBlock, Command, EngineState, Stack};
|
use nu_protocol::engine::{CaptureBlock, Command, EngineState, Stack};
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
Category, Example, IntoInterruptiblePipelineData, PipelineData, Signature, Span, SyntaxShape,
|
Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, Signature,
|
||||||
Value,
|
Span, SyntaxShape, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@ -150,13 +150,13 @@ impl Command for Each {
|
|||||||
val: idx as i64,
|
val: idx as i64,
|
||||||
span,
|
span,
|
||||||
},
|
},
|
||||||
x,
|
x.clone(),
|
||||||
],
|
],
|
||||||
span,
|
span,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
stack.add_var(*var_id, x);
|
stack.add_var(*var_id, x.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,7 +165,7 @@ impl Command for Each {
|
|||||||
&engine_state,
|
&engine_state,
|
||||||
&mut stack,
|
&mut stack,
|
||||||
&block,
|
&block,
|
||||||
PipelineData::new(span),
|
x.into_pipeline_data(),
|
||||||
redirect_stdout,
|
redirect_stdout,
|
||||||
redirect_stderr,
|
redirect_stderr,
|
||||||
) {
|
) {
|
||||||
@ -201,13 +201,13 @@ impl Command for Each {
|
|||||||
val: idx as i64,
|
val: idx as i64,
|
||||||
span,
|
span,
|
||||||
},
|
},
|
||||||
x,
|
x.clone(),
|
||||||
],
|
],
|
||||||
span,
|
span,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
stack.add_var(*var_id, x);
|
stack.add_var(*var_id, x.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -216,7 +216,7 @@ impl Command for Each {
|
|||||||
&engine_state,
|
&engine_state,
|
||||||
&mut stack,
|
&mut stack,
|
||||||
&block,
|
&block,
|
||||||
PipelineData::new(span),
|
x.into_pipeline_data(),
|
||||||
redirect_stdout,
|
redirect_stdout,
|
||||||
redirect_stderr,
|
redirect_stderr,
|
||||||
) {
|
) {
|
||||||
@ -228,7 +228,7 @@ impl Command for Each {
|
|||||||
PipelineData::Value(x, ..) => {
|
PipelineData::Value(x, ..) => {
|
||||||
if let Some(var) = block.signature.get_positional(0) {
|
if let Some(var) = block.signature.get_positional(0) {
|
||||||
if let Some(var_id) = &var.var_id {
|
if let Some(var_id) = &var.var_id {
|
||||||
stack.add_var(*var_id, x);
|
stack.add_var(*var_id, x.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,7 +236,7 @@ impl Command for Each {
|
|||||||
&engine_state,
|
&engine_state,
|
||||||
&mut stack,
|
&mut stack,
|
||||||
&block,
|
&block,
|
||||||
PipelineData::new(span),
|
x.into_pipeline_data(),
|
||||||
redirect_stdout,
|
redirect_stdout,
|
||||||
redirect_stderr,
|
redirect_stderr,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user