diff --git a/crates/nu-command/src/debug/inspect.rs b/crates/nu-command/src/debug/inspect.rs index bb7edcaf5..56f96a053 100644 --- a/crates/nu-command/src/debug/inspect.rs +++ b/crates/nu-command/src/debug/inspect.rs @@ -34,6 +34,11 @@ impl Command for Inspect { ) -> Result { let input_metadata = input.metadata(); let input_val = input.into_value(call.head); + if input_val.is_nothing() { + return Err(ShellError::PipelineEmpty { + dst_span: call.head, + }); + } let original_input = input_val.clone(); let description = match input_val { Value::CustomValue { ref val, .. } => val.value_string(), diff --git a/crates/nu-command/tests/commands/inspect.rs b/crates/nu-command/tests/commands/inspect.rs new file mode 100644 index 000000000..efa401479 --- /dev/null +++ b/crates/nu-command/tests/commands/inspect.rs @@ -0,0 +1,7 @@ +use nu_test_support::nu; + +#[test] +fn inspect_with_empty_pipeline() { + let actual = nu!("inspect"); + assert!(actual.err.contains("no input value was piped in")); +} diff --git a/crates/nu-command/tests/commands/mod.rs b/crates/nu-command/tests/commands/mod.rs index 8da49708b..c5ce4c814 100644 --- a/crates/nu-command/tests/commands/mod.rs +++ b/crates/nu-command/tests/commands/mod.rs @@ -37,6 +37,7 @@ mod headers; mod help; mod histogram; mod insert; +mod inspect; mod into_filesize; mod into_int; mod join;