projects
/
cgilite
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
290cc67
)
allow `check` function for field indexes
master
author
Paul Hänsch
<paul@plutz.net>
Sun, 6 Apr 2025 10:03:07 +0000
(12:03 +0200)
committer
Paul Hänsch
<paul@plutz.net>
Sun, 6 Apr 2025 10:03:07 +0000
(12:03 +0200)
db23.sh
patch
|
blob
|
history
diff --git
a/db23.sh
b/db23.sh
index e8a0d64da8bf0b15c7c74398fe7200d68ad16680..8ee6f4fe528ab3e96b9c2cc4bc41fe697220b099 100755
(executable)
--- a/
db23.sh
+++ b/
db23.sh
@@
-31,8
+31,12
@@
DB2() {
open|load) file="$1"
cat "$file" || return 1
;;
open|load) file="$1"
cat "$file" || return 1
;;
- check|contains) key="$(STRING "$1")"
val=''
+ check|contains) key="$(STRING "$1")"
seq="${2:-1}"
val="${data##*"${BR}${key}" }" val="${val%%"${BR}"*}"
val="${data##*"${BR}${key}" }" val="${val%%"${BR}"*}"
+ [ "$val" = '' ] && return 1 || val="${val} "
+ while [ $seq -gt 1 ]; do
+ seq=$((seq - 1)) val="${val#* }"
+ done
[ "$val" = '' ] && return 1
;;
count) key="$(STRING "$1")" val='' seq=0
[ "$val" = '' ] && return 1
;;
count) key="$(STRING "$1")" val='' seq=0