correctly merge and reformat custom json into generated config

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
Steven Armstrong 2015-08-13 20:45:31 +02:00
parent 31dddca0db
commit c3bf4c7b61

View file

@ -126,10 +126,10 @@ if [ -f "$__object/parameter/json-config" ]; then
if [ "$json_config" = "-" ]; then
json_config="$__object/stdin"
fi
printf ','
# remove trailing ,
json=$(cat "$json_config")
echo "${json%*,}"
# remove leading and trailing whitespace and commas from first and last line
# indent each line with 3 spaces for consistency
json=$(sed -e 's/^[ \t]*/ /' -e '1s/^[ \t,]*//' -e '$s/[ \t,]*$//' "$json_config")
printf ' ,%s\n' "$json"
fi
echo "}"
) | \