mirror of
https://github.com/nushell/nushell.git
synced 2024-11-25 01:43:47 +01:00
Fix quoted string handling
This commit is contained in:
parent
2e2831de95
commit
75b7842618
@ -145,7 +145,6 @@ fn process_line(
|
|||||||
|
|
||||||
for item in parsed {
|
for item in parsed {
|
||||||
input = match process_command(
|
input = match process_command(
|
||||||
crate::parser::print_items(&item),
|
|
||||||
item.clone(),
|
item.clone(),
|
||||||
input,
|
input,
|
||||||
context.clone(),
|
context.clone(),
|
||||||
@ -181,13 +180,13 @@ fn process_line(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn process_command(
|
fn process_command(
|
||||||
line: String,
|
|
||||||
parsed: Vec<crate::parser::Item>,
|
parsed: Vec<crate::parser::Item>,
|
||||||
input: VecDeque<Value>,
|
input: VecDeque<Value>,
|
||||||
context: Arc<Mutex<Context>>,
|
context: Arc<Mutex<Context>>,
|
||||||
) -> Result<VecDeque<Value>, ShellError> {
|
) -> Result<VecDeque<Value>, ShellError> {
|
||||||
let command = &parsed[0].name()?;
|
let command = &parsed[0].name()?;
|
||||||
let arg_list = parsed[1..].iter().map(|i| i.as_value()).collect();
|
let arg_list = parsed[1..].iter().map(|i| i.as_value()).collect();
|
||||||
|
let arg_list_strings: Vec<String> = parsed[1..].iter().map(|i| i.print()).collect();
|
||||||
|
|
||||||
if command == &"format" {
|
if command == &"format" {
|
||||||
format(input, context);
|
format(input, context);
|
||||||
@ -225,7 +224,11 @@ fn process_command(
|
|||||||
}
|
}
|
||||||
|
|
||||||
false => {
|
false => {
|
||||||
Exec::shell(line).cwd(ctx.env.cwd()).join().unwrap();
|
Exec::shell(command)
|
||||||
|
.args(&arg_list_strings)
|
||||||
|
.cwd(ctx.env.cwd())
|
||||||
|
.join()
|
||||||
|
.unwrap();
|
||||||
Ok(VecDeque::new())
|
Ok(VecDeque::new())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
crate mod completer;
|
crate mod completer;
|
||||||
crate mod parse;
|
crate mod parse;
|
||||||
|
|
||||||
crate use self::parse::{print_items, shell_parser, Item};
|
crate use self::parse::{shell_parser, Item};
|
||||||
|
@ -65,18 +65,16 @@ impl Item {
|
|||||||
Item::Operator(o) => Value::Primitive(Primitive::Operator(o.clone())),
|
Item::Operator(o) => Value::Primitive(Primitive::Operator(o.clone())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
crate fn print_items(items: &[Item]) -> String {
|
pub fn print(&self) -> String {
|
||||||
let formatted = items.iter().map(|item| match item {
|
match self {
|
||||||
Item::Bare(s) => format!("{}", s),
|
Item::Bare(s) => format!("{}", s),
|
||||||
Item::Quoted(s) => format!("{:?}", s),
|
Item::Quoted(s) => format!("{}", s),
|
||||||
Item::Int(i) => format!("{:?}", i),
|
Item::Int(i) => format!("{:?}", i),
|
||||||
Item::Boolean(b) => format!("{:?}", b),
|
Item::Boolean(b) => format!("{:?}", b),
|
||||||
Item::Operator(o) => o.print(),
|
Item::Operator(o) => o.print(),
|
||||||
});
|
}
|
||||||
|
}
|
||||||
itertools::join(formatted, " ")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Item {
|
impl Item {
|
||||||
|
Loading…
Reference in New Issue
Block a user