mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-12 13:48:06 +00:00
Need to escape single quotes in bash, updated docs #1932
This commit is contained in:
parent
2473068a1a
commit
6e21c9f77f
@ -168,8 +168,8 @@ fruit:
|
|||||||
then
|
then
|
||||||
```bash
|
```bash
|
||||||
yq '.[] |(
|
yq '.[] |(
|
||||||
( select(kind == "scalar") | key + "='" + . + "'"),
|
( select(kind == "scalar") | key + "='\''" + . + "'\''"),
|
||||||
( select(kind == "seq") | key + "=(" + (map("'" + . + "'") | join(",")) + ")")
|
( select(kind == "seq") | key + "=(" + (map("'\''" + . + "'\''") | join(",")) + ")")
|
||||||
)' sample.yml
|
)' sample.yml
|
||||||
```
|
```
|
||||||
will output
|
will output
|
||||||
@ -203,8 +203,8 @@ deep:
|
|||||||
then
|
then
|
||||||
```bash
|
```bash
|
||||||
yq '.. |(
|
yq '.. |(
|
||||||
( select(kind == "scalar" and parent | kind != "seq") | (path | join("_")) + "='" + . + "'"),
|
( select(kind == "scalar" and parent | kind != "seq") | (path | join("_")) + "='\''" + . + "'\''"),
|
||||||
( select(kind == "seq") | (path | join("_")) + "=(" + (map("'" + . + "'") | join(",")) + ")")
|
( select(kind == "seq") | (path | join("_")) + "=(" + (map("'\''" + . + "'\''") | join(",")) + ")")
|
||||||
)' sample.yml
|
)' sample.yml
|
||||||
```
|
```
|
||||||
will output
|
will output
|
||||||
|
@ -317,7 +317,7 @@ func documentInput(w *bufio.Writer, s expressionScenario) (string, string) {
|
|||||||
writeOrPanic(w, "then\n")
|
writeOrPanic(w, "then\n")
|
||||||
|
|
||||||
if s.expression != "" {
|
if s.expression != "" {
|
||||||
writeOrPanic(w, fmt.Sprintf("```bash\n%vyq %v'%v' %v\n```\n", envCommand, command, s.expression, files))
|
writeOrPanic(w, fmt.Sprintf("```bash\n%vyq %v'%v' %v\n```\n", envCommand, command, strings.ReplaceAll(s.expression, "'", `'\''`), files))
|
||||||
} else {
|
} else {
|
||||||
writeOrPanic(w, fmt.Sprintf("```bash\n%vyq %v%v\n```\n", envCommand, command, files))
|
writeOrPanic(w, fmt.Sprintf("```bash\n%vyq %v%v\n```\n", envCommand, command, files))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user