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