diff --git a/crates/nu-command/src/filters/get.rs b/crates/nu-command/src/filters/get.rs index f9b8e9a9e..048117577 100644 --- a/crates/nu-command/src/filters/get.rs +++ b/crates/nu-command/src/filters/get.rs @@ -74,7 +74,29 @@ impl Command for Get { Err(_) => Ok(Value::Nothing { span: call.head }.into_pipeline_data()), } } else { - output + match output { + Ok(val) => { + let val_check = val.into_value(span); + match val_check { + Value::List { + ref vals, + span: spanchild, + } => { + if vals.iter().any(|unit| unit.is_empty()) { + Err(nu_protocol::ShellError::CantFindColumn( + "Empty cell".to_string(), + spanchild, + span, + )) + } else { + Ok(val_check.into_pipeline_data()) + } + } + val => Ok(val.into_pipeline_data()), + } + } + Err(e) => Err(e), + } } } else { let mut output = vec![]; @@ -87,8 +109,18 @@ impl Command for Get { let val = input.clone().follow_cell_path(&path.members, !sensitive); if ignore_errors { - if let Ok(val) = val { - output.push(val); + match val { + Ok(Value::Nothing { span: spanchild }) => { + return Err(nu_protocol::ShellError::CantFindColumn( + "Nothing".to_string(), + spanchild, + span, + )); + } + Ok(val) => { + output.push(val); + } + Err(_) => {} } } else { output.push(val?); diff --git a/crates/nu-command/tests/commands/cal.rs b/crates/nu-command/tests/commands/cal.rs index 70261fd4c..6fe361861 100644 --- a/crates/nu-command/tests/commands/cal.rs +++ b/crates/nu-command/tests/commands/cal.rs @@ -71,7 +71,7 @@ fn cal_sees_pipeline_year() { let actual = nu!( cwd: ".", pipeline( r#" - cal --full-year 1020 | get monday | first 4 | to json -r + cal --full-year 1020 | get -i monday | first 4 | to json -r "# )); diff --git a/crates/nu-command/tests/commands/where_.rs b/crates/nu-command/tests/commands/where_.rs index 2cd5609c8..6841144dc 100644 --- a/crates/nu-command/tests/commands/where_.rs +++ b/crates/nu-command/tests/commands/where_.rs @@ -16,7 +16,7 @@ fn filters_by_unit_size_comparison() { fn filters_with_nothing_comparison() { let actual = nu!( cwd: "tests/fixtures/formats", - r#"'[{"foo": 3}, {"foo": null}, {"foo": 4}]' | from json | get foo | compact | where $it > 1 | math sum"# + r#"'[{"foo": 3}, {"foo": null}, {"foo": 4}]' | from json | get -i foo | compact | where $it > 1 | math sum"# ); assert_eq!(actual.out, "7");