enable support for phone number types
[confetti] / actions / update_card.sh
index a810476..f18c9ee 100755 (executable)
@@ -47,9 +47,10 @@ UID:${_POST[UID]}
 $(
 for field in $VCF_FIELDS; do
   for key in $field $field{0..100}; do
-    [ -z "$_POST[$key]" ] && break
+    [ -z "${_POST[$key]+x}" ] && break
     value="$(printf %s "$_POST[$key]" |sed -r ':a;N;$!ba;s:\n:\\n:g;s:\r:\\r:g')"
-    printf '%s:%s\n' "${field}" "$value"
+    [ "${key%%[0-9]*}" = TEL ] && tag="TYPE=${_POST[phonetype${key#TEL}]}" || tag=''
+    [ -n "$value" ] && printf '%s:%s\n' "${field}${tag:+;$tag}" "$value"
   done
 done
 [ "${_POST[action]}" = addfield ] && printf '%s:\n' "${_POST[newfield]}"