From da1c1d9c76c6912ae2f2ff776b98d59bd4482618 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Sun, 19 Jan 2020 18:07:30 +0100 Subject: [PATCH] update card from temp file (bugfix), avoid some odd formatting --- cards/update_card.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cards/update_card.sh b/cards/update_card.sh index c13b6ec..fd0b210 100755 --- a/cards/update_card.sh +++ b/cards/update_card.sh @@ -61,9 +61,12 @@ vcf_escape(){ # [ -n "${_POST[hi_company]}${_POST[hi_number]}${_POST[hi_status]}" ] \ # && _POST[X-HEALTH-INSURANCE]="$(vcf_escape "${_POST[hi_company]}" "${_POST[hi_number]}" "${_POST[hi_status]}")" -vcf="$(pdi_load "$cardfile")" +# vcf="$(pdi_load "$cardfile")" +vcf="$(pdi_load "$tempfile")" vcf="$(pdi_update_value "$vcf" N 1 "$(vcf_escape "$(POST 1N)" "$(POST 2N)" "$(POST 3N)" "$(POST 4N)" "$(POST 5N)")")" +vcf="$(pdi_update_value "$vcf" FN 1 "$(vcf_escape "$(POST 4N) $(POST 2N) $(POST 3N) $(POST 1N) $(POST 5N)" \ + | sed -E 's;^ +;;; s; +$;;; s; +; ;g;')" )" for field in $(POST_KEYS |grep -xE '[A-Z][A-Z0-9-]*'); do for cnt in $(seq 1 $(POST_COUNT "$field")); do @@ -108,7 +111,7 @@ vcf="$(printf '%s\n' "$vcf" |sed -E "/^[^:]+:delete=${delete_key}\$/d")" if [ "$action" = addfield ]; then vcf="$(pdi_update_value "$vcf" "$newfield" $(( $(pdi_count "$vcf" "$newfield") + 1 )) '')" fi -printf '%s' "$vcf" |grep -vx '' >"$tempfile" +printf '%s' "$vcf" | sed -E '/^$/d; s/^([^:]+);:/\1:/;' >"$tempfile" case "$action" in addfield) -- 2.39.2