diff --git a/crates/nu-command/tests/commands/get.rs b/crates/nu-command/tests/commands/get.rs index 693bd0967d..c5eeea5122 100644 --- a/crates/nu-command/tests/commands/get.rs +++ b/crates/nu-command/tests/commands/get.rs @@ -219,3 +219,13 @@ fn quoted_column_access() { assert_eq!(actual.out, "4"); } + +#[test] +fn get_does_not_delve_too_deep_in_nested_lists() { + let actual = nu!( + cwd: ".", + r#"[[{foo: bar}]] | get foo"# + ); + + assert!(actual.err.contains("did not find anything under this name")); +} diff --git a/crates/nu-command/tests/commands/open.rs b/crates/nu-command/tests/commands/open.rs index af5266cfc4..5bce98f045 100644 --- a/crates/nu-command/tests/commands/open.rs +++ b/crates/nu-command/tests/commands/open.rs @@ -179,7 +179,7 @@ fn parses_json() { fn parses_xml() { let actual = nu!( cwd: "tests/fixtures/formats", - "open jonathan.xml | get rss.children.channel.children | get item.children | get link.children.0.3.3.0" + "open jonathan.xml | get rss.children.channel.children | get 0.item.children | get 0.link.children.0.0" ); assert_eq!( diff --git a/crates/nu-protocol/src/value/mod.rs b/crates/nu-protocol/src/value/mod.rs index d1070cbd50..110d627348 100644 --- a/crates/nu-protocol/src/value/mod.rs +++ b/crates/nu-protocol/src/value/mod.rs @@ -717,6 +717,7 @@ impl Value { let mut output = vec![]; let mut hasvalue = false; let mut temp: Result = Err(ShellError::NotFound(*span)); + let vals = vals.iter().filter(|v| matches!(v, Value::Record { .. })); for val in vals { temp = val.clone().follow_cell_path( &[PathMember::String {