mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
Add escapes to 'to nuon' (#4964)
This commit is contained in:
@ -137,10 +137,15 @@ fn value_to_string(v: &Value, span: Span) -> Result<String, ShellError> {
|
||||
}
|
||||
Ok(format!("{{{}}}", collection.join(", ")))
|
||||
}
|
||||
Value::String { val, .. } => Ok(format!("\"{}\"", val)),
|
||||
Value::String { val, .. } => Ok(format!("\"{}\"", escape(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);
|
||||
|
||||
|
Reference in New Issue
Block a user