aboutsummaryrefslogtreecommitdiff
path: root/tests/manifest-serializer/driver.in
blob: 4ee31a78f5ca73e184ef9145ef75e0b8b07cda40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env bash

# file      : tests/manifest-serializer/driver.in
# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd
# license   : MIT; see accompanying LICENSE file

trap "{ exit 1; }" ERR
set -o errtrace # Trap ERR in functions.

@import libbutl/manifest-serializer@

butl_manifest_serializer_start "$@"

fd="$butl_manifest_serializer_ifd"

while read -r n; do
  printf "%s:" "$n" >&"$fd"

  f=true
  while read -r v; do
    if [ -z "$v" ]; then
      printf "\0" >&"$fd"
      break
    else
      if [ "$f" ]; then
	f=
      else
	printf "\n" >&"$fd"
      fi
      printf "%s" "$v" >&"$fd"
    fi
  done
done

butl_manifest_serializer_finish