aboutsummaryrefslogtreecommitdiff
path: root/libbutl/manifest-serializer.bash.in
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-04-08 16:36:39 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2019-04-08 18:35:10 +0300
commit8b0fe501e77a1f4032a396b97ad317f09e160ee3 (patch)
tree54b59aa6fb696d12e2eaac711fe35246627bf0a4 /libbutl/manifest-serializer.bash.in
parentc66eacd1d56cebce6986217bf6ea321018323952 (diff)
Add support for manifest serializing long lines mode
Diffstat (limited to 'libbutl/manifest-serializer.bash.in')
-rw-r--r--libbutl/manifest-serializer.bash.in26
1 files changed, 20 insertions, 6 deletions
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 <file> is not specified, then write to stdout.
+# If <file> 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 () # [<file>]
+function butl_manifest_serializer_start () # [--long-lines] [<file>]
{
+ 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 () # [<file>]
# 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"
}