Fix quoting for command line args (#5384)

* Fix quoting for command line args

* Replace custom quoting with escape_quote_string

* Use raw string for now
This commit is contained in:
Tomoki Aonuma
2022-05-01 03:23:05 +09:00
committed by GitHub
parent 9da2e142b2
commit ae9c0fc138
5 changed files with 39 additions and 46 deletions

View File

@ -1,5 +1,6 @@
use core::fmt::Write;
use nu_engine::get_columns;
use nu_parser::escape_quote_string;
use nu_protocol::ast::{Call, RangeInclusion};
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{
@ -137,15 +138,10 @@ fn value_to_string(v: &Value, span: Span) -> Result<String, ShellError> {
}
Ok(format!("{{{}}}", collection.join(", ")))
}
Value::String { val, .. } => Ok(format!("\"{}\"", escape(val))),
Value::String { val, .. } => Ok(escape_quote_string(val)),
}
}
fn escape(input: &str) -> String {
let output = input.replace('\\', "\\\\");
output.replace('"', "\\\"")
}
fn to_nuon(call: &Call, input: PipelineData) -> Result<String, ShellError> {
let v = input.into_value(call.head);