forked from extern/nushell
throw an error instead of a panic if no input is provided to inspect
(#9259)
# Description This is a small PR to fix Nu crashing when calling `inspect` with no data piped in(#9255). # User-Facing Changes none.
This commit is contained in:
parent
a6e455efc3
commit
60041879f3
@ -34,6 +34,11 @@ impl Command for Inspect {
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
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(),
|
||||
|
7
crates/nu-command/tests/commands/inspect.rs
Normal file
7
crates/nu-command/tests/commands/inspect.rs
Normal file
@ -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"));
|
||||
}
|
@ -37,6 +37,7 @@ mod headers;
|
||||
mod help;
|
||||
mod histogram;
|
||||
mod insert;
|
||||
mod inspect;
|
||||
mod into_filesize;
|
||||
mod into_int;
|
||||
mod join;
|
||||
|
Loading…
Reference in New Issue
Block a user