diff --git a/crates/nu-cli/tests/commands/get.rs b/crates/nu-cli/tests/commands/get.rs index 95e3d3dc54..5b80287cb3 100644 --- a/crates/nu-cli/tests/commands/get.rs +++ b/crates/nu-cli/tests/commands/get.rs @@ -235,3 +235,13 @@ fn errors_fetching_by_index_out_of_bounds() { ) }) } + +#[test] +fn quoted_column_access() { + let actual = nu!( + cwd: "tests/fixtures/formats", + r#"echo '[{"foo bar": {"baz": 4}}]' | from-json | get "foo bar".baz | echo $it"# + ); + + assert_eq!(actual, "4"); +} diff --git a/crates/nu-parser/src/lite_parse.rs b/crates/nu-parser/src/lite_parse.rs index 2ba14f5364..dbd76c0a67 100644 --- a/crates/nu-parser/src/lite_parse.rs +++ b/crates/nu-parser/src/lite_parse.rs @@ -104,45 +104,6 @@ fn bare(src: &mut Input, span_offset: usize) -> Result, ParseErr Ok(bare.spanned(span)) } -fn quoted( - src: &mut Input, - delimiter: char, - span_offset: usize, -) -> Result, ParseError> { - skip_whitespace(src); - - let mut quoted_string = String::new(); - let start_offset = if let Some((pos, _)) = src.peek() { - *pos - } else { - 0 - }; - - let _ = src.next(); - - let mut found_end = false; - - for (_, c) in src { - if c != delimiter { - quoted_string.push(c); - } else { - found_end = true; - break; - } - } - - quoted_string.insert(0, delimiter); - if found_end { - quoted_string.push(delimiter); - } - - let span = Span::new( - start_offset + span_offset, - start_offset + span_offset + quoted_string.len(), - ); - Ok(quoted_string.spanned(span)) -} - fn command(src: &mut Input, span_offset: usize) -> Result { let command = bare(src, span_offset)?; if command.item.is_empty() { @@ -193,12 +154,12 @@ fn pipeline(src: &mut Input, span_offset: usize) -> Result { - let c = *c; - // quoted string - let arg = quoted(src, c, span_offset)?; - cmd.args.push(arg); - } + // '"' | '\'' => { + // let c = *c; + // // quoted string + // let arg = quoted(src, c, span_offset)?; + // cmd.args.push(arg); + // } _ => { // basic argument let arg = bare(src, span_offset)?;