mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-07 02:48:27 +08:00
Need to escape single quotes in bash, updated docs #1932
This commit is contained in:
+4
-4
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user