Fix to nuon --serialize of closure (#15357)

# Description
Closes #15351

Adds quotes that were missed in #14698 with the proper escaping.


# User-Facing Changes
`to nuon --serialize` will now produce a quoted string instead of
illegal nuon when given a closure

# Tests + Formatting
Reenable the `to nuon` rejection of closures in the base state test.
Added test for quoting.
This commit is contained in:
Stefan Holderbach
2025-03-20 17:50:36 +01:00
committed by GitHub
parent 2ea2a904e8
commit 7a6cfa24fc
3 changed files with 17 additions and 4 deletions

View File

@ -99,7 +99,9 @@ fn value_to_string(
}
Value::Closure { val, .. } => {
if serialize_types {
Ok(val.coerce_into_string(engine_state, span)?.to_string())
Ok(escape_quote_string(
&val.coerce_into_string(engine_state, span)?,
))
} else {
Err(ShellError::UnsupportedInput {
msg: "closures are currently not deserializable (use --serialize to serialize as a string)".into(),