fix bug in bash v5 when allocating new ids

This commit is contained in:
Rob Pearce 2022-08-29 21:02:05 +10:00
parent 4c29f1a4a0
commit db20b09954
1 changed files with 16 additions and 4 deletions

14
t.sh
View File

@ -143,10 +143,17 @@ function getuid() {
function updatenextid() {
local nextid2=1
local db=0
nextid2=1
if [[ $b5 -eq 1 ]]; then
while [[ " ${i_idmap[@]}" == *\ $nextid2* ]]; do
nextid2=$((nextid2 + 1))
done
else
while [[ " ${taskid[@]}" == *\ $nextid2* ]]; do
nextid2=$((nextid2 + 1))
done
fi
nextid=$nextid2
}
@ -175,6 +182,7 @@ function loadids() {
id=${LINE#*:}
#uid=$(echo "$LINE" | sed 's/:.*$//g')
#id=$(echo "$LINE" | sed 's/^.*://g')
addidmap $id $uid
if [[ -z $uid || -z $id ]]; then
error "invalid idmapping line: '$LINE'"
@ -318,6 +326,7 @@ function confirm() {
function loadtask() {
local uid sum checked folded desc file id parent res i cats
local blockreason
local didalloc=0
#local re
#if iscached "$1"; then
@ -341,7 +350,7 @@ dblog "process token '${tok[$i]}'"
if [[ -z $id ]]; then
id=$nextid
addidmap $nextid $uid
updatenextid
didalloc=1
needsave=1
fi
elif [[ ${tok[$i]} == "sum" ]]; then
@ -388,6 +397,9 @@ dblog "process token '${tok[$i]}'"
[[ $id -gt $maxid ]] && maxid=$id
[[ ${#sum} -gt $taskwid ]] && taskwid=${#sum}
[[ ${#desc} -gt $taskwid ]] && taskwid=${#desc}
[[ $didalloc -eq 1 ]] && updatenextid
if [[ -z $uid ]]; then
error "task has no uid:"
echo "$res"