Fix bug where tasks with ID > 255 aren't shown.
This commit is contained in:
parent
82c3860e65
commit
71d4229b59
27
t.sh
27
t.sh
|
@ -122,7 +122,7 @@ function getuid() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getorgenid() {
|
function getorgenid() {
|
||||||
local res uid
|
local res uid v=0
|
||||||
uid=$1
|
uid=$1
|
||||||
res=$(getid $uid)
|
res=$(getid $uid)
|
||||||
if [[ -z $res ]]; then
|
if [[ -z $res ]]; then
|
||||||
|
@ -131,7 +131,7 @@ function getorgenid() {
|
||||||
nextid=$((nextid + 1))
|
nextid=$((nextid + 1))
|
||||||
needsave=1
|
needsave=1
|
||||||
fi
|
fi
|
||||||
return $res
|
echo "$res"
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadids() {
|
function loadids() {
|
||||||
|
@ -162,7 +162,7 @@ function saveids() {
|
||||||
local id
|
local id
|
||||||
cp /dev/null $idfile
|
cp /dev/null $idfile
|
||||||
for id in ${!idmap[@]}; do
|
for id in ${!idmap[@]}; do
|
||||||
dblog "save to $idfile: uid ${idmap[$id]} id $id sum ${tasksum[$id]}" >> $idfile
|
#dblog "save to $idfile: uid ${idmap[$id]} id $id sum ${tasksum[$id]}" >> $idfile
|
||||||
echo "${idmap[$id]}:$id" >> $idfile
|
echo "${idmap[$id]}:$id" >> $idfile
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ function getindentlevel() { ## $0 id
|
||||||
parentuid=${taskparent[$thisid]}
|
parentuid=${taskparent[$thisid]}
|
||||||
if [[ ! -z $parentuid ]]; then
|
if [[ ! -z $parentuid ]]; then
|
||||||
thisid=$(getid $parentuid)
|
thisid=$(getid $parentuid)
|
||||||
dblog " gil() parent uid: [$parentuid] id: [$thisid]"
|
dblog " parent uid: [$parentuid] id: [$thisid]"
|
||||||
level=$((level + 1))
|
level=$((level + 1))
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -239,7 +239,7 @@ function getindentlevel() { ## $0 id
|
||||||
}
|
}
|
||||||
|
|
||||||
function dblog() {
|
function dblog() {
|
||||||
[[ $DEBUG -eq 1 ]] && echo "$(date) $*" >/dev/stderr
|
[[ $DEBUG -eq 1 ]] && echo "$(date) ${FUNCNAME[1]}() $*" >/dev/stderr
|
||||||
}
|
}
|
||||||
|
|
||||||
function action() {
|
function action() {
|
||||||
|
@ -271,6 +271,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
|
||||||
|
|
||||||
|
dblog "open $1"
|
||||||
file="$1"
|
file="$1"
|
||||||
res=$(cat $file | awk -F: 'BEGIN { checked=0; folded=0; } /^UID:/ { printf("uid©%s©",$2); } /^SUMMARY:/ { sub("SUMMARY:",""); printf("sum©%s©",$0); } /^CATEGORIES:/ { sub("^CATEGORIES:",""); printf("cats©%s©",$0); } /^DESCRIPTION:/ { sub("DESCRIPTION:",""); printf("desc©%s©",$0); } /^RELATED-TO/ { sub("^RELATED-TO.*:",""); printf("parent©%s©",$0); } /^X-OC-HIDESUBTASKS:1/ { folded=1; } /^STATUS:COMPLETED/ { checked=1; } END { printf("checked©%d©folded©%d\n",checked,folded); }')
|
res=$(cat $file | awk -F: 'BEGIN { checked=0; folded=0; } /^UID:/ { printf("uid©%s©",$2); } /^SUMMARY:/ { sub("SUMMARY:",""); printf("sum©%s©",$0); } /^CATEGORIES:/ { sub("^CATEGORIES:",""); printf("cats©%s©",$0); } /^DESCRIPTION:/ { sub("DESCRIPTION:",""); printf("desc©%s©",$0); } /^RELATED-TO/ { sub("^RELATED-TO.*:",""); printf("parent©%s©",$0); } /^X-OC-HIDESUBTASKS:1/ { folded=1; } /^STATUS:COMPLETED/ { checked=1; } END { printf("checked©%d©folded©%d\n",checked,folded); }')
|
||||||
|
|
||||||
|
@ -287,14 +288,13 @@ function loadtask() {
|
||||||
# i=$((i + 1))
|
# i=$((i + 1))
|
||||||
# done
|
# done
|
||||||
while [[ ! -z ${tok[$i]} ]]; do
|
while [[ ! -z ${tok[$i]} ]]; do
|
||||||
#dblog "process token '${tok[$i]}'"
|
dblog "process token '${tok[$i]}'"
|
||||||
if [[ ${tok[$i]} == "uid" ]]; then
|
if [[ ${tok[$i]} == "uid" ]]; then
|
||||||
uid=${tok[$((i + 1))]}
|
uid=${tok[$((i + 1))]}
|
||||||
#nexti=$((i + 1))
|
#nexti=$((i + 1))
|
||||||
#dblog "i=$i tok[i]=${tok[$i]} i+1=$((i + 1)) tok[i+1]=${tok[$((i + 1))]} uid $uid id $id"
|
#dblog "i=$i tok[i]=${tok[$i]} i+1=$((i + 1)) tok[i+1]=${tok[$((i + 1))]} uid $uid id $id"
|
||||||
#dblog "i=$i tok[i]=${tok[$i]} i+1=$((i + 1)) tok[nexti]=${tok[$nexti]} uid $uid id $id"
|
#dblog "i=$i tok[i]=${tok[$i]} i+1=$((i + 1)) tok[nexti]=${tok[$nexti]} uid $uid id $id"
|
||||||
getorgenid $uid
|
id=$(getorgenid $uid)
|
||||||
id=$?
|
|
||||||
#dblog "i=$i tok[i]=${tok[$i]} uid $uid id $id"
|
#dblog "i=$i tok[i]=${tok[$i]} uid $uid id $id"
|
||||||
elif [[ ${tok[$i]} == "sum" ]]; then
|
elif [[ ${tok[$i]} == "sum" ]]; then
|
||||||
sum="${tok[$((i + 1))]}"
|
sum="${tok[$((i + 1))]}"
|
||||||
|
@ -322,6 +322,17 @@ function loadtask() {
|
||||||
taskfolded[$id]=$folded
|
taskfolded[$id]=$folded
|
||||||
taskparent[$id]=$parent
|
taskparent[$id]=$parent
|
||||||
|
|
||||||
|
if [[ $DEBUG -eq 1 ]]; then
|
||||||
|
echo "taskuid[$id]=$uid"
|
||||||
|
echo "taskid[$id]=$id"
|
||||||
|
echo "tasksum[$id]=$sum"
|
||||||
|
echo "taskcats[$id]=$cats"
|
||||||
|
echo "taskdesc[$id]=$desc"
|
||||||
|
echo "taskchecked[$id]=$checked"
|
||||||
|
echo "taskfolded[$id]=$folded"
|
||||||
|
echo "taskparent[$id]=$parent"
|
||||||
|
fi
|
||||||
|
|
||||||
[[ $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}
|
||||||
|
|
Loading…
Reference in New Issue