Improve $in handling (#5137)

* Simplify in logic

* Add tests

* more tests, and fixes
This commit is contained in:
JT
2022-04-09 09:41:05 +12:00
committed by GitHub
parent 0892a16a3d
commit 97eb8492a3
5 changed files with 57 additions and 11 deletions

View File

@ -1,7 +1,9 @@
use nu_engine::{eval_block, CallExt};
use nu_protocol::ast::Call;
use nu_protocol::engine::{CaptureBlock, Command, EngineState, Stack};
use nu_protocol::{Category, Example, PipelineData, Signature, SyntaxShape, Value};
use nu_protocol::{
Category, Example, IntoPipelineData, PipelineData, Signature, SyntaxShape, Value,
};
#[derive(Clone)]
pub struct Collect;
@ -42,7 +44,7 @@ impl Command for Collect {
if let Some(var) = block.signature.get_positional(0) {
if let Some(var_id) = &var.var_id {
stack.add_var(*var_id, input);
stack.add_var(*var_id, input.clone());
}
}
@ -50,7 +52,7 @@ impl Command for Collect {
engine_state,
&mut stack,
&block,
PipelineData::new(call.head),
input.into_pipeline_data(),
call.redirect_stdout,
call.redirect_stderr,
)

View File

@ -89,7 +89,8 @@ impl Command for FromNuon {
let (lite_block, err) = nu_parser::lite_parse(&lexed);
error = error.or(err);
let (mut block, err) = nu_parser::parse_block(&mut working_set, &lite_block, true, &[]);
let (mut block, err) =
nu_parser::parse_block(&mut working_set, &lite_block, true, &[], false);
error = error.or(err);
if let Some(pipeline) = block.pipelines.get(1) {