Skip to content

https://mikefarah.gitbook.io/yq/recipes#export-as-environment-variables-script-or-any-custom-format doesn't work #1932

Closed
@jakub-bochenski

Description

$ yq --version
yq (https://github.com/mikefarah/yq/) version v4.40.5
$ echo 'simple: string0
simpleArray:
  - apple
  - banana
  - peach
deep:
  property: value
  array:
    - cat' | yq '.. |(
        ( select(kind == "scalar" and parent | kind != "seq") | (path | join("_")) + "='" + . + "'"),
        ( select(kind == "seq") | (path | join("_")) + "=(" + (map("'" + . + "'") | join(",")) + ")")
)'
simple= + . + 
deep_property= + . + 
simpleArray=( + . + , + . + , + . + )
deep_array=( + . + )

I believe this is caused by wrong escaping.
If you use single quote to quote the string, you need to escape single quotes inside...

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions