upcase=' y;abcdefghijklmnopqrstuvwxyzäöüé;ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜÉ;; '
card_fullname(){
- local card="$1" n1 n2 n3 n4 n5
+ local card="$1" N n1 n2 n3 n4 n5
- local N="$(pdi_value "$card" N)"
- local FN="$(pdi_value "$card" FN)"
- local NICKNAME="$(pdi_value "$card" NICKNAME)"
-
- if [ "$FN" ]; then
- printf %s "$FN"
- elif [ "$N" ]; then
+ if pdi_value "$card" FN; then
+ return
+ elif N="$(pdi_value "$card" N)"; then
IFS=\; read n1 n2 n3 n4 n5 <<-EOF
$(pdi_value "$card" N)
EOF
printf '%s %s %s %s %s' "$n4" "$n2" "$n3" "$n1" "$n5"
- elif [ "$NICKNAME" ]; then
- printf '"%s"' "$NICKNAME"
+ else
+ pdi_value "$card" NICKNAME
fi
}
'"$upcase""$fex"
}
+order_cards() {
+ local cardfile card
+ echo ORDER $order >&2
+
+ while read cardfile; do
+ card="$(pdi_load "$cardfile")"
+
+ case $order in
+ firstname)
+ printf '%s %s\n' "$(card_fullname "$card")" "$cardfile"
+ ;;
+ lastname)
+ printf '%s %s\n' "$(pdi_value "$card" N || card_fullname "$card")" "$cardfile"
+ ;;
+ bdate)
+ printf '%s %s\n' "$(pdi_value "$card" BDAY || printf 0000-00-00)" "$cardfile"
+ ;;
+ esac
+ done \
+ | sort \
+ | sed -E 's;^.*\t;;g'
+}
+
list_cards(){
filter_cards \
+ | order_cards \
| while read cardfile; do
print_card "$cardfile"
done
pdi_attrib(){
local card=":$1" name="$2" cnt="${3:-1}"
while [ $cnt -gt 0 ]; do
+ [ "${card#*${BR}${name};}" = "$card" ] && return 1
card="${card#*${BR}${name};}"
cnt=$((cnt - 1))
done
pdi_value(){
local card="${BR}$1" name="$2" cnt="${3:-1}"
while [ $cnt -gt 0 ]; do
+ [ "${card#*${BR}${name};*:}" = "$card" ] && return 1
card="${card#*${BR}${name};*:}"
cnt=$((cnt - 1))
done