# -*- mode: shell-script -*- yaml_opt_flatten() { local prefix="$1" key value while read-0 key value; do if [ "$prefix" ]; then new_prefix="${prefix}-${key}" else new_prefix="${key}" fi if [[ "$(echo "$value" | shyaml get-type)" == "struct" ]]; then echo "$value" | yaml_opt_flatten "${new_prefix}" else printf "%s\0%s\0" "${new_prefix}" "$value" fi done < <(shyaml key-values-0) }