Repository navigation
No way of adding --- separator when a single bare document is processed (e.g. split_doc doesn't)
#2976
Replies: 1 comment 2 replies
|
The boundary that matters here is the yq process, not just the YAML file. With For a file set that fits the OS argument limit, pass all paths to one yq invocation. In Bash 4.4+: mapfile -d '' -t yaml_files < <(
find "$HOME" -type f -name '*yaml' -print0
)
if ((${#yaml_files[@]})); then
yq eval '.' "${yaml_files[@]}"
fiThe NUL-delimited collection handles spaces/newlines in paths, and the empty-array check avoids This follows the documented multi-file evaluation This does not force |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hello.
I usually do
findyaml files and executeyqon them in the following way (or similar).When a yaml file contains a single "bare document" (one not beginning with any directives, e.g. %YAML 1.2, or marker lines, e.g.
---), its output is appended to the output of the last document of the previous yaml file, without any separation. So two or more documents are basically united. This is important for example when one needs to pipe the result further.split_docis not adding a separator when given a single document (if there isn't one already). Also, there is no option, only--no-docwhich does the reverse (not printing a separator).The following very similar approach also doesn't work, even though it seems to
In fact, in this case, the number of arguments provided by
findtoyqis variable, and I noticed that in some cases the bare documents are not splitted.I'm asking this as a question, in case I missed some details before opening an issue.
Edit.
How to add a --- marker for each document, even for bare documents in single-file jq invocations?
In case there is no answer, I'll open an issue. In my opinion,
split_docfilter should always put markers, e.g. given asample.yamlfile ofthen
should output
For multi-files
jqinvocations the answer is basically in Tips and tricks.Thanks
All reactions