case $call in
new|discard)
- printf '\n'
+ printf ''
;;
open|load) file="$1"
cat "$file" || return 1
set|store) key="$(STRING "$1")" val=""
shift 1
val="$(for v in "$@"; do STRING "$v"; printf \\t; done)"
- if [ "${data#${BR}${key} *}" != "$data" ]; then
+ if [ "${data#*${BR}${key} *}" != "$data" ]; then
data="${data%${BR}${key} *${BR}*}${BR}${key} ${val% }${BR}${data#*${BR}${key} *${BR}}"
data="${data#${BR}}" data="${data%${BR}}"
else
data="${data#${BR}}${key} ${val% }${BR}"
+ data="${data#${BR}}"
fi
printf %s\\n "${data}"
;;
- flush|save|write) file="$1"
- data="${data#${BR}}" data="${data%${BR}}"
- if LOCK "$file"; then
- printf '%s\n' "$data" >"$file"
- RELEASE "$file"
- else
+ append) key="$(STRING "$1")" val=""
+ val="${data##*${BR}${key} }" val="${val%%${BR}*}"
+ if [ "$val" = '' ]; then
+ printf %s\\n "${data}"
return 1
+ else
+ shift 1
+ val="${val}$(for v in "$@"; do printf \\t; STRING "$v"; done)"
+ data="${data%${BR}${key} *${BR}*}${BR}${key} ${val% }${BR}${data#*${BR}${key} *${BR}}"
+ data="${data#${BR}}" data="${data%${BR}}"
+ printf %s\\n "${data}"
fi
;;
+ flush|save|write) file="$1"
+ data="${data#${BR}}" data="${data%${BR}}"
+ printf '%s\n' "$data" >"$file" || return 1
+ ;;
esac
return 0
}
# by always keeping file data in $db3_data
case "$1" in
- new|discard|open|load|delete|remove|set|store)
+ new|discard|open|load|delete|remove|set|store|append)
db3_data="$(DB2 "$db3_data" "$@")"
return "$?"
;;