From 30eeafefe167140350ecd4034c9689ab4dd9857d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Wed, 27 Jan 2021 13:17:34 +0100 Subject: [PATCH] always write FN field; bugfix: use editing tempfile as basis for modifications, important when setting up new card --- cards/update_card.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cards/update_card.sh b/cards/update_card.sh index 4ae9c19..d942e9a 100755 --- a/cards/update_card.sh +++ b/cards/update_card.sh @@ -62,9 +62,14 @@ 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 "$tempfile")" -vcf="$(pdi_update_value "$vcf" N 1 "$(vcf_escape "$(POST 1N)" "$(POST 2N)" "$(POST 3N)" "$(POST 4N)" "$(POST 5N)")")" +n1="$(POST 1N)" n2="$(POST 2N)" n3="$(POST 3N)" n4="$(POST 4N)" n5="$(POST 5N)" +# 3N (Middle Names) is not actually used +n3="${n2#${n2%% *}}" + +vcf="$(pdi_update_value "$vcf" N 1 "$(vcf_escape "$n1" "${n2%% *}" "${n3# }" "$n4" "$n5")")" +vcf="$(pdi_update_value "$vcf" FN 1 "$(vcf_escape "$n4 $n2 $n1 $n5" |sed -E 's;(^ +| +$);;g; s; +; ;g;')")" vcf="$(printf '%s\n' "$vcf" |sed -E "/^CATEGORIES;[^:]*:.*$/d")" for field in $(POST_KEYS |grep -xE '[A-Z][A-Z0-9-]*'); do -- 2.39.2