From 8b0fe501e77a1f4032a396b97ad317f09e160ee3 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 8 Apr 2019 16:36:39 +0300 Subject: Add support for manifest serializing long lines mode --- libbutl/manifest-serializer.bash.in | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'libbutl/manifest-serializer.bash.in') diff --git a/libbutl/manifest-serializer.bash.in b/libbutl/manifest-serializer.bash.in index b1220e1..06770ba 100644 --- a/libbutl/manifest-serializer.bash.in +++ b/libbutl/manifest-serializer.bash.in @@ -11,13 +11,13 @@ fi @import libbutl/utility@ # Serialize the manifest reading the binary representation from stdin and -# writing to stdout. +# writing to stdout. Unless --long-lines is specified, break lines in values. # # Normally you would use the start/finish functions below. # -function butl_serialize_manifest () +function butl_serialize_manifest () # [--long-lines] { - "$(butl_path)/manifest" serialize + "$(butl_path)/manifest" "$@" serialize } # Start the manifest serialization co-process setting the following "return" @@ -27,7 +27,8 @@ function butl_serialize_manifest () # butl_manifest_serializer_ofd # butl_manifest_serializer_pid # -# If is not specified, then write to stdout. +# If is not specified, then write to stdout. Unless --long-lines is +# specified, break lines in values. # # The typical usage: # @@ -41,8 +42,21 @@ function butl_serialize_manifest () # # butl_manifest_serializer_finish # -function butl_manifest_serializer_start () # [] +function butl_manifest_serializer_start () # [--long-lines] [] { + local ops=() + while [ $# -gt 0 ]; do + case "$1" in + --long-lines) + ops+=("$1") + shift + ;; + *) + break + ;; + esac + done + if [ "$#" -gt 0 ]; then exec {butl_manifest_serializer_ofd}>"$1" else @@ -51,7 +65,7 @@ function butl_manifest_serializer_start () # [] # See notes in butl_manifest_parser_start() on bash co-process issues. # - coproc { butl_serialize_manifest; } >&"$butl_manifest_serializer_ofd" + coproc { butl_serialize_manifest "${ops[@]}"; } >&"$butl_manifest_serializer_ofd" butl_manifest_serializer_ifd="${COPROC[1]}" butl_manifest_serializer_pid="$COPROC_PID" } -- cgit v1.1