Improve empty pipelines (#7383)

# Description

This fix changes pipelines to allow them to actually be empty. Mapping
over empty pipelines gives empty pipelines. Empty pipelines immediately
return `None` when iterated.

This removes a some of where `Span::new(0, 0)` was coming from, though
there are other cases where we still use it.

# User-Facing Changes

None

# Tests + Formatting

Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
This commit is contained in:
JT
2022-12-08 07:31:57 +13:00
committed by GitHub
parent d18587330a
commit eaec480f42
80 changed files with 194 additions and 190 deletions

View File

@ -43,10 +43,10 @@ impl Command for Alias {
&self,
_engine_state: &EngineState,
_stack: &mut Stack,
call: &Call,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -37,14 +37,13 @@ impl Command for Ast {
call: &Call,
_input: PipelineData,
) -> Result<PipelineData, ShellError> {
let head = call.head;
let pipeline: Spanned<String> = call.req(engine_state, stack, 0)?;
let mut working_set = StateWorkingSet::new(engine_state);
let (output, err) = parse(&mut working_set, None, pipeline.item.as_bytes(), false, &[]);
eprintln!("output: {:#?}\nerror: {:#?}", output, err);
Ok(PipelineData::new(head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -36,10 +36,10 @@ impl Command for Def {
&self,
_engine_state: &EngineState,
_stack: &mut Stack,
call: &Call,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -62,10 +62,10 @@ def-env cd_with_fallback [arg = ""] {
&self,
_engine_state: &EngineState,
_stack: &mut Stack,
call: &Call,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -169,9 +169,9 @@ impl Command for Do {
trim_end_newline,
}),
Ok(PipelineData::Value(Value::Error { .. }, ..)) if ignore_shell_errors => {
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
Err(_) if ignore_shell_errors => Ok(PipelineData::new(call.head)),
Err(_) if ignore_shell_errors => Ok(PipelineData::empty()),
r => r,
}
}

View File

@ -39,10 +39,10 @@ impl Command for ExportAlias {
&self,
_engine_state: &EngineState,
_stack: &mut Stack,
call: &Call,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -36,10 +36,10 @@ impl Command for ExportDef {
&self,
_engine_state: &EngineState,
_stack: &mut Stack,
call: &Call,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -62,10 +62,10 @@ export def-env cd_with_fallback [arg = ""] {
&self,
_engine_state: &EngineState,
_stack: &mut Stack,
call: &Call,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -35,10 +35,10 @@ impl Command for ExportExtern {
&self,
_engine_state: &EngineState,
_stack: &mut Stack,
call: &Call,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -34,10 +34,10 @@ impl Command for ExportUse {
&self,
_engine_state: &EngineState,
_stack: &mut Stack,
call: &Call,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -35,10 +35,10 @@ impl Command for Extern {
&self,
_engine_state: &EngineState,
_stack: &mut Stack,
call: &Call,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -110,7 +110,7 @@ impl Command for For {
&engine_state,
stack,
&block,
PipelineData::new(head),
PipelineData::empty(),
redirect_stdout,
redirect_stderr,
) {
@ -155,7 +155,7 @@ impl Command for For {
&engine_state,
stack,
&block,
PipelineData::new(head),
PipelineData::empty(),
redirect_stdout,
redirect_stderr,
) {
@ -181,14 +181,14 @@ impl Command for For {
&engine_state,
stack,
&block,
PipelineData::new(head),
PipelineData::empty(),
redirect_stdout,
redirect_stderr,
)?
.into_value(head);
}
}
Ok(PipelineData::new(head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -62,7 +62,7 @@ This command is a parser keyword. For details, check:
stack.remove_env_var(engine_state, &env_var_name.item);
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -63,7 +63,7 @@ impl Command for HideEnv {
}
}
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -102,7 +102,7 @@ impl Command for If {
.map(|res| res.0)
}
} else {
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
}
x => Err(ShellError::CantConvert(

View File

@ -32,7 +32,7 @@ impl Command for Ignore {
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
input.into_value(call.head);
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -73,7 +73,7 @@ impl Command for Let {
//println!("Adding: {:?} to {}", rhs, var_id);
stack.add_var(var_id, rhs.into_value(call.head));
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -55,7 +55,7 @@ impl Command for Loop {
engine_state,
stack,
block,
PipelineData::new(call.head),
PipelineData::empty(),
call.redirect_stdout,
call.redirect_stderr,
) {
@ -73,7 +73,7 @@ impl Command for Loop {
}
}
}
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -35,10 +35,10 @@ impl Command for Module {
&self,
_engine_state: &EngineState,
_stack: &mut Stack,
call: &Call,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -73,7 +73,7 @@ impl Command for Mut {
//println!("Adding: {:?} to {}", rhs, var_id);
stack.add_var(var_id, rhs.into_value(call.head));
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -88,7 +88,7 @@ impl Command for OverlayHide {
stack.add_env_var(name, val);
}
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -49,7 +49,7 @@ This command is a parser keyword. For details, check:
stack.add_overlay(name_arg.item);
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -172,7 +172,7 @@ impl Command for OverlayUse {
caller_stack.add_overlay(overlay_name);
}
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -49,10 +49,10 @@ impl Command for Register {
&self,
_engine_state: &EngineState,
_stack: &mut Stack,
call: &Call,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -71,12 +71,12 @@ impl Command for Try {
engine_state,
stack,
catch_block,
PipelineData::new(call.head),
PipelineData::empty(),
false,
false,
)
} else {
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
}
// external command may fail to run
@ -118,12 +118,12 @@ impl Command for Try {
engine_state,
stack,
catch_block,
PipelineData::new(call.head),
PipelineData::empty(),
false,
false,
)
} else {
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
} else {
Ok(PipelineData::ExternalStream {

View File

@ -112,7 +112,7 @@ impl Command for Use {
));
}
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -63,7 +63,7 @@ impl Command for While {
engine_state,
stack,
block,
PipelineData::new(call.head),
PipelineData::empty(),
call.redirect_stdout,
call.redirect_stderr,
) {
@ -94,7 +94,7 @@ impl Command for While {
}
}
}
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -22,7 +22,7 @@ pub fn test_dataframe(cmds: Vec<Box<dyn Command + 'static>>) {
let delta = {
// Base functions that are needed for testing
// Try to keep this working set small to keep tests running as fast as possible
let mut working_set = StateWorkingSet::new(&*engine_state);
let mut working_set = StateWorkingSet::new(&engine_state);
working_set.add_decl(Box::new(Let));
working_set.add_decl(Box::new(ToDataFrame));
working_set.add_decl(Box::new(ToLazyFrame));
@ -49,7 +49,7 @@ pub fn test_dataframe(cmds: Vec<Box<dyn Command + 'static>>) {
let start = std::time::Instant::now();
let (block, delta) = {
let mut working_set = StateWorkingSet::new(&*engine_state);
let mut working_set = StateWorkingSet::new(&engine_state);
let (output, err) = parse(
&mut working_set,
None,
@ -75,7 +75,7 @@ pub fn test_dataframe(cmds: Vec<Box<dyn Command + 'static>>) {
&engine_state,
&mut stack,
&block,
PipelineData::new(Span::test_data()),
PipelineData::empty(),
true,
true,
) {

View File

@ -108,6 +108,6 @@ impl Command for ConfigReset {
}
}
}
Ok(PipelineData::new(span))
Ok(PipelineData::empty())
}
}

View File

@ -50,7 +50,7 @@ impl Command for ExportEnv {
redirect_env(engine_state, caller_stack, &callee_stack);
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -57,7 +57,7 @@ impl Command for LetEnv {
} else {
stack.add_env_var(env_var.item, rhs);
}
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -57,7 +57,7 @@ impl Command for LoadEnv {
stack.add_env_var(env_var, rhs);
}
}
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
None => match input {
PipelineData::Value(Value::Record { cols, vals, .. }, ..) => {
@ -81,7 +81,7 @@ impl Command for LoadEnv {
stack.add_env_var(env_var, rhs);
}
}
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
_ => Err(ShellError::UnsupportedInput(
"'load-env' expects a single record".into(),

View File

@ -59,7 +59,7 @@ mod test_examples {
let delta = {
// Base functions that are needed for testing
// Try to keep this working set small to keep tests running as fast as possible
let mut working_set = StateWorkingSet::new(&*engine_state);
let mut working_set = StateWorkingSet::new(&engine_state);
working_set.add_decl(Box::new(Let));
working_set.add_decl(Box::new(Str));
working_set.add_decl(Box::new(StrJoin));
@ -215,10 +215,10 @@ mod test_examples {
);
engine_state
.merge_env(&mut stack, &cwd)
.merge_env(&mut stack, cwd)
.expect("Error merging environment");
let empty_input = PipelineData::new(Span::test_data());
let empty_input = PipelineData::empty();
let result = eval(example.example, empty_input, cwd, engine_state);
// Note. Value implements PartialEq for Bool, Int, Float, String and Block
@ -320,7 +320,7 @@ mod test_examples {
block.pipelines[0].elements.truncate(&n_expressions - 1);
if !block.pipelines[0].elements.is_empty() {
let empty_input = PipelineData::new(Span::test_data());
let empty_input = PipelineData::empty();
Some(eval_block(block, empty_input, cwd, engine_state, delta))
} else {
Some(Value::nothing(Span::test_data()))

View File

@ -196,7 +196,7 @@ impl Command for Cd {
match have_permission(&path_tointo) {
PermissionResult::PermissionOk => {
stack.add_env_var("PWD".into(), path_value);
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
PermissionResult::PermissionDenied(reason) => Err(ShellError::IOError(format!(
"Cannot change directory to {}: {}",

View File

@ -2,8 +2,7 @@ use nu_engine::CallExt;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{
Category, Example, PipelineData, RawStream, ShellError, Signature, Span, Spanned, SyntaxShape,
Value,
Category, Example, PipelineData, RawStream, ShellError, Signature, Spanned, SyntaxShape, Value,
};
use std::fs::File;
use std::io::{BufWriter, Write};
@ -160,7 +159,7 @@ impl Command for Save {
file.flush()?
}
Ok(PipelineData::new(span))
Ok(PipelineData::empty())
}
Value::Binary { val, .. } => {
if let Err(err) = file.write_all(&val) {
@ -169,7 +168,7 @@ impl Command for Save {
file.flush()?
}
Ok(PipelineData::new(span))
Ok(PipelineData::empty())
}
Value::List { vals, .. } => {
let val = vals
@ -185,7 +184,7 @@ impl Command for Save {
file.flush()?
}
Ok(PipelineData::new(span))
Ok(PipelineData::empty())
}
v => Err(ShellError::UnsupportedInput(
format!("{:?} not supported", v.get_type()),
@ -194,7 +193,7 @@ impl Command for Save {
}
} else {
match input {
PipelineData::ExternalStream { stdout: None, .. } => Ok(PipelineData::new(span)),
PipelineData::ExternalStream { stdout: None, .. } => Ok(PipelineData::empty()),
PipelineData::ExternalStream {
stdout: Some(stream),
stderr,
@ -202,16 +201,16 @@ impl Command for Save {
} => {
// delegate a thread to redirect stderr to result.
let handler = stderr.map(|stderr_stream| match stderr_file {
Some(stderr_file) => std::thread::spawn(move || {
stream_to_file(stderr_stream, stderr_file, span)
}),
Some(stderr_file) => {
std::thread::spawn(move || stream_to_file(stderr_stream, stderr_file))
}
None => std::thread::spawn(move || {
let _ = stderr_stream.into_bytes();
Ok(PipelineData::new(span))
Ok(PipelineData::empty())
}),
});
let res = stream_to_file(stream, file, span);
let res = stream_to_file(stream, file);
if let Some(h) = handler {
match h.join() {
Err(err) => {
@ -236,7 +235,7 @@ impl Command for Save {
file.flush()?
}
Ok(PipelineData::new(span))
Ok(PipelineData::empty())
}
Value::Binary { val, .. } => {
if let Err(err) = file.write_all(&val) {
@ -245,7 +244,7 @@ impl Command for Save {
file.flush()?
}
Ok(PipelineData::new(span))
Ok(PipelineData::empty())
}
Value::List { vals, .. } => {
let val = vals
@ -261,7 +260,7 @@ impl Command for Save {
file.flush()?
}
Ok(PipelineData::new(span))
Ok(PipelineData::empty())
}
v => Err(ShellError::UnsupportedInput(
format!("{:?} not supported", v.get_type()),
@ -303,11 +302,7 @@ impl Command for Save {
}
}
fn stream_to_file(
mut stream: RawStream,
file: File,
span: Span,
) -> Result<PipelineData, ShellError> {
fn stream_to_file(mut stream: RawStream, file: File) -> Result<PipelineData, ShellError> {
let mut writer = BufWriter::new(file);
stream
@ -331,5 +326,5 @@ fn stream_to_file(
}
Ok(())
})
.map(|_| PipelineData::new(span))
.map(|_| PipelineData::empty())
}

View File

@ -190,7 +190,7 @@ impl Command for Touch {
}
}
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -271,7 +271,7 @@ impl Command for Watch {
}
}
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -72,6 +72,7 @@ fn getcol(
input: PipelineData,
) -> Result<PipelineData, ShellError> {
match input {
PipelineData::Empty => Ok(PipelineData::Empty),
PipelineData::Value(
Value::List {
vals: input_vals,

View File

@ -156,6 +156,7 @@ with 'transpose' first."#
let redirect_stderr = call.redirect_stderr;
match input {
PipelineData::Empty => Ok(PipelineData::Empty),
PipelineData::Value(Value::Range { .. }, ..)
| PipelineData::Value(Value::List { .. }, ..)
| PipelineData::ListStream { .. } => Ok(input
@ -223,7 +224,7 @@ with 'transpose' first."#
}
})
.into_pipeline_data(ctrlc)),
PipelineData::ExternalStream { stdout: None, .. } => Ok(PipelineData::new(call.head)),
PipelineData::ExternalStream { stdout: None, .. } => Ok(PipelineData::empty()),
PipelineData::ExternalStream {
stdout: Some(stream),
..

View File

@ -116,6 +116,7 @@ impl Command for EachWhile {
let redirect_stderr = call.redirect_stderr;
match input {
PipelineData::Empty => Ok(PipelineData::Empty),
PipelineData::Value(Value::Range { .. }, ..)
| PipelineData::Value(Value::List { .. }, ..)
| PipelineData::ListStream { .. } => Ok(input
@ -186,7 +187,7 @@ impl Command for EachWhile {
})
.fuse()
.into_pipeline_data(ctrlc)),
PipelineData::ExternalStream { stdout: None, .. } => Ok(PipelineData::new(call.head)),
PipelineData::ExternalStream { stdout: None, .. } => Ok(PipelineData::empty()),
PipelineData::ExternalStream {
stdout: Some(stream),
..

View File

@ -103,6 +103,7 @@ fn empty(
.into_pipeline_data())
} else {
match input {
PipelineData::Empty => Ok(PipelineData::Empty),
PipelineData::ExternalStream { stdout, .. } => match stdout {
Some(s) => {
let bytes = s.into_bytes();

View File

@ -321,6 +321,7 @@ fn find_with_rest_and_highlight(
let ls_colors = get_ls_colors(ls_colors_env_str);
match input {
PipelineData::Empty => Ok(PipelineData::Empty),
PipelineData::Value(_, _) => input
.map(
move |mut x| match &mut x {
@ -446,7 +447,7 @@ fn find_with_rest_and_highlight(
)
.into_pipeline_data(ctrlc)
.set_metadata(meta)),
PipelineData::ExternalStream { stdout: None, .. } => Ok(PipelineData::new(span)),
PipelineData::ExternalStream { stdout: None, .. } => Ok(PipelineData::empty()),
PipelineData::ExternalStream {
stdout: Some(stream),
..

View File

@ -110,7 +110,7 @@ impl Command for Last {
if let Some(last) = last {
Ok(last.into_pipeline_data().set_metadata(metadata))
} else {
Ok(PipelineData::new(span).set_metadata(metadata))
Ok(PipelineData::empty().set_metadata(metadata))
}
}
}

View File

@ -97,6 +97,7 @@ fn getcol(
input: PipelineData,
) -> Result<PipelineData, ShellError> {
match input {
PipelineData::Empty => Ok(PipelineData::Empty),
PipelineData::Value(
Value::List {
vals: input_vals,

View File

@ -71,6 +71,7 @@ impl Command for Lines {
Ok(iter.into_pipeline_data(engine_state.ctrlc.clone()))
}
PipelineData::Empty => Ok(PipelineData::Empty),
PipelineData::ListStream(stream, ..) => {
let iter = stream
.into_iter()
@ -112,7 +113,7 @@ impl Command for Lines {
format!("Not supported input: {}", val.as_string()?),
head,
)),
PipelineData::ExternalStream { stdout: None, .. } => Ok(PipelineData::new(head)),
PipelineData::ExternalStream { stdout: None, .. } => Ok(PipelineData::empty()),
PipelineData::ExternalStream {
stdout: Some(stream),
..

View File

@ -81,6 +81,7 @@ impl Command for ParEach {
let redirect_stderr = call.redirect_stderr;
match input {
PipelineData::Empty => Ok(PipelineData::Empty),
PipelineData::Value(Value::Range { val, .. }, ..) => Ok(val
.into_range_iter(ctrlc.clone())?
.enumerate()
@ -272,7 +273,7 @@ impl Command for ParEach {
.into_iter()
.flatten()
.into_pipeline_data(ctrlc)),
PipelineData::ExternalStream { stdout: None, .. } => Ok(PipelineData::new(call.head)),
PipelineData::ExternalStream { stdout: None, .. } => Ok(PipelineData::empty()),
PipelineData::ExternalStream {
stdout: Some(stream),
..

View File

@ -219,7 +219,7 @@ impl Command for Reduce {
engine_state,
&mut stack,
block,
PipelineData::new(span),
PipelineData::empty(),
// redirect stdout until its the last input value
redirect_stdout || input_iter.peek().is_some(),
redirect_stderr,

View File

@ -249,7 +249,7 @@ fn select(
Ok(v.into_pipeline_data().set_metadata(metadata))
}
}
_ => Ok(PipelineData::new(span)),
_ => Ok(PipelineData::empty()),
}
}

View File

@ -96,7 +96,7 @@ impl Command for SkipUntil {
&engine_state,
&mut stack,
&block,
PipelineData::new(span),
PipelineData::empty(),
redirect_stdout,
redirect_stderr,
)

View File

@ -97,7 +97,7 @@ impl Command for SkipWhile {
&engine_state,
&mut stack,
&block,
PipelineData::new(span),
PipelineData::empty(),
redirect_stdout,
redirect_stderr,
)

View File

@ -92,7 +92,7 @@ impl Command for TakeUntil {
&engine_state,
&mut stack,
&block,
PipelineData::new(span),
PipelineData::empty(),
redirect_stdout,
redirect_stderr,
)

View File

@ -92,7 +92,7 @@ impl Command for TakeWhile {
&engine_state,
&mut stack,
&block,
PipelineData::new(span),
PipelineData::empty(),
redirect_stdout,
redirect_stderr,
)

View File

@ -62,6 +62,7 @@ impl Command for Where {
let redirect_stderr = call.redirect_stderr;
match input {
PipelineData::Empty => Ok(PipelineData::Empty),
PipelineData::Value(Value::Range { .. }, ..)
| PipelineData::Value(Value::List { .. }, ..)
| PipelineData::ListStream { .. } => Ok(input
@ -115,9 +116,7 @@ impl Command for Where {
}
})
.into_pipeline_data(ctrlc)),
PipelineData::ExternalStream { stdout: None, .. } => {
Ok(PipelineData::new(call.head))
}
PipelineData::ExternalStream { stdout: None, .. } => Ok(PipelineData::empty()),
PipelineData::ExternalStream {
stdout: Some(stream),
..

View File

@ -39,6 +39,7 @@ impl Command for Wrap {
let name: String = call.req(engine_state, stack, 0)?;
match input {
PipelineData::Empty => Ok(PipelineData::Empty),
PipelineData::Value(Value::Range { .. }, ..)
| PipelineData::Value(Value::List { .. }, ..)
| PipelineData::ListStream { .. } => Ok(input

View File

@ -54,7 +54,7 @@ impl Command for History {
if clear {
let _ = std::fs::remove_file(history_path);
// TODO: FIXME also clear the auxiliary files when using sqlite
Ok(PipelineData::new(head))
Ok(PipelineData::empty())
} else {
let history_reader: Option<Box<dyn ReedlineHistory>> =
match engine_state.config.history_file_format {

View File

@ -176,7 +176,7 @@ impl Command for SubCommand {
file.flush()?
}
Ok(PipelineData::new(span))
Ok(PipelineData::empty())
}
Value::Binary { val, .. } => {
if let Err(err) = file.write_all(&val) {
@ -185,7 +185,7 @@ impl Command for SubCommand {
file.flush()?
}
Ok(PipelineData::new(span))
Ok(PipelineData::empty())
}
Value::List { vals, .. } => {
let val = vals
@ -201,7 +201,7 @@ impl Command for SubCommand {
file.flush()?
}
Ok(PipelineData::new(span))
Ok(PipelineData::empty())
}
v => Err(ShellError::UnsupportedInput(
format!("{:?} not supported", v.get_type()),
@ -211,7 +211,7 @@ impl Command for SubCommand {
} else {
match value {
PipelineData::ExternalStream { stdout: None, .. } => {
Ok(PipelineData::new(span))
Ok(PipelineData::empty())
}
PipelineData::ExternalStream {
stdout: Some(mut stream),
@ -240,7 +240,7 @@ impl Command for SubCommand {
}
Ok(())
})
.map(|_| PipelineData::new(span))
.map(|_| PipelineData::empty())
}
value => match value.into_value(span) {
Value::String { val, .. } => {
@ -250,7 +250,7 @@ impl Command for SubCommand {
file.flush()?
}
Ok(PipelineData::new(span))
Ok(PipelineData::empty())
}
Value::Binary { val, .. } => {
if let Err(err) = file.write_all(&val) {
@ -259,7 +259,7 @@ impl Command for SubCommand {
file.flush()?
}
Ok(PipelineData::new(span))
Ok(PipelineData::empty())
}
Value::List { vals, .. } => {
let val = vals
@ -275,7 +275,7 @@ impl Command for SubCommand {
file.flush()?
}
Ok(PipelineData::new(span))
Ok(PipelineData::empty())
}
v => Err(ShellError::UnsupportedInput(
format!("{:?} not supported", v.get_type()),

View File

@ -99,7 +99,7 @@ impl Command for Enter {
stack.add_env_var("PWD".into(), new_path);
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {

View File

@ -101,7 +101,7 @@ impl Command for Exit {
stack.add_env_var("PWD".into(), new_path);
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
}

View File

@ -121,7 +121,7 @@ fn switch_shell(
stack.add_env_var("PWD".into(), new_path);
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
fn list_shells(

View File

@ -180,7 +180,7 @@ fn detect_columns(
})
.into_pipeline_data(ctrlc))
} else {
Ok(PipelineData::new(name_span))
Ok(PipelineData::empty())
}
}

View File

@ -66,7 +66,7 @@ documentation link at https://docs.rs/encoding_rs/0.8.28/encoding_rs/#statics"#
let encoding: Spanned<String> = call.req(engine_state, stack, 0)?;
match input {
PipelineData::ExternalStream { stdout: None, .. } => Ok(PipelineData::new(call.head)),
PipelineData::ExternalStream { stdout: None, .. } => Ok(PipelineData::empty()),
PipelineData::ExternalStream {
stdout: Some(stream),
..

View File

@ -66,7 +66,7 @@ documentation link at https://docs.rs/encoding_rs/0.8.28/encoding_rs/#statics"#
let encoding: Spanned<String> = call.req(engine_state, stack, 0)?;
match input {
PipelineData::ExternalStream { stdout: None, .. } => Ok(PipelineData::new(call.head)),
PipelineData::ExternalStream { stdout: None, .. } => Ok(PipelineData::empty()),
PipelineData::ExternalStream {
stdout: Some(stream),
..

View File

@ -44,7 +44,7 @@ impl Command for Benchmark {
engine_state,
&mut stack,
block,
PipelineData::new(call.head),
PipelineData::empty(),
redirect_stdout,
redirect_stderr,
)?

View File

@ -88,7 +88,7 @@ prints out the list properly."#
use_grid_icons,
)?)
} else {
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
}
PipelineData::ListStream(stream, ..) => {
@ -106,7 +106,7 @@ prints out the list properly."#
)?)
} else {
// dbg!(data);
Ok(PipelineData::new(call.head))
Ok(PipelineData::empty())
}
}
PipelineData::Value(Value::Record { cols, vals, .. }, ..) => {