mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-01 14:14:52 +08:00
Use a lazy-quoting @sh encoder (#1548)
* Use a lazy-quoting @sh encoder * Add internal quoting style switch to @sh * Add test for stray empty quotes in @sh
This commit is contained in:
@@ -263,9 +263,19 @@ var encoderDecoderOperatorScenarios = []expressionScenario{
|
||||
document: "coolData: strings with spaces and a 'quote'",
|
||||
expression: ".coolData | @sh",
|
||||
expected: []string{
|
||||
"D0, P[coolData], (!!str)::'strings with spaces and a \\'quote\\''\n",
|
||||
"D0, P[coolData], (!!str)::strings' with spaces and a '\\'quote\\'\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "Encode a string to sh",
|
||||
subdescription: "Watch out for stray '' (empty strings)",
|
||||
document: "coolData: \"'starts, contains more '' and ends with a quote'\"",
|
||||
expression: ".coolData | @sh",
|
||||
expected: []string{
|
||||
"D0, P[coolData], (!!str)::\\'starts,' contains more '\\'\\'' and ends with a quote'\\'\n",
|
||||
},
|
||||
skipDoc: true,
|
||||
},
|
||||
{
|
||||
description: "Decode a base64 encoded string",
|
||||
subdescription: "Decoded data is assumed to be a string.",
|
||||
|
||||
Reference in New Issue
Block a user