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

20
t.sh
View File

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