fix spaces in file/dir/calendar names breaking several commands.
This commit is contained in:
parent
404839bd7a
commit
58bc83e53e
106
t.sh
106
t.sh
|
@ -376,15 +376,15 @@ function marknotdone() {
|
||||||
error "$noun #${id} is already unfinished"
|
error "$noun #${id} is already unfinished"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
file=$dir/$uid.vcf
|
file="$dir/$uid.vcf"
|
||||||
sed -i '/^COMPLETED:/d;/^STATUS:COMPLETED/d;/PERCENT-COMPLETE:100/d' $file
|
sed -i '/^COMPLETED:/d;/^STATUS:COMPLETED/d;/PERCENT-COMPLETE:100/d' "$file"
|
||||||
sedrv=$((sedrv + $?))
|
sedrv=$((sedrv + $?))
|
||||||
set_lastmodified $uid
|
set_lastmodified $uid
|
||||||
sedrv=$((sedrv + $?))
|
sedrv=$((sedrv + $?))
|
||||||
if [[ $sedrv -eq 0 ]]; then
|
if [[ $sedrv -eq 0 ]]; then
|
||||||
action "Marked $noun #${id} as unfinished."
|
action "Marked $noun #${id} as unfinished."
|
||||||
processed="$processed ${uid} "
|
processed="$processed ${uid} "
|
||||||
loadtask $file
|
loadtask "$file"
|
||||||
rv=0
|
rv=0
|
||||||
children=$(getchildren $uid)
|
children=$(getchildren $uid)
|
||||||
for childuid in ${children}; do
|
for childuid in ${children}; do
|
||||||
|
@ -445,8 +445,8 @@ function delq_process() {
|
||||||
if [[ $? -eq 0 ]]; then
|
if [[ $? -eq 0 ]]; then
|
||||||
count=0
|
count=0
|
||||||
for uid in $deluids; do
|
for uid in $deluids; do
|
||||||
file=$dir/$uid.vcf
|
file="$dir/$uid.vcf"
|
||||||
rm -f $file
|
rm -f "$file"
|
||||||
|
|
||||||
id=$(getid $uid)
|
id=$(getid $uid)
|
||||||
unset idmap[$id]
|
unset idmap[$id]
|
||||||
|
@ -467,9 +467,9 @@ function delq_process() {
|
||||||
function set_lastmodified() {
|
function set_lastmodified() {
|
||||||
local uid file now
|
local uid file now
|
||||||
uid=$1
|
uid=$1
|
||||||
file=$dir/$uid.vcf
|
file="$dir/$uid.vcf"
|
||||||
now=$(date -u +'%Y%m%dT%H%M%SZ')
|
now=$(date -u +'%Y%m%dT%H%M%SZ')
|
||||||
sed -i "s/^LAST-MODIFIED:.*/LAST-MODIFIED:$now/" $file
|
sed -i "s/^LAST-MODIFIED:.*/LAST-MODIFIED:$now/" "$file"
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -490,15 +490,15 @@ function move_left() { # move_left uid
|
||||||
parent2=${taskparent[$parentid]}
|
parent2=${taskparent[$parentid]}
|
||||||
taskparent[$id]="$parent2"
|
taskparent[$id]="$parent2"
|
||||||
|
|
||||||
file=$dir/$uid.vcf
|
file="$dir/$uid.vcf"
|
||||||
|
|
||||||
sed -i "s/^RELATED-TO.*/RELATED-TO;RELTYPE=PARENT:${taskparent[$id]}/" $file
|
sed -i "s/^RELATED-TO.*/RELATED-TO;RELTYPE=PARENT:${taskparent[$id]}/" "$file"
|
||||||
sedrv=$?
|
sedrv=$?
|
||||||
set_lastmodified $uid
|
set_lastmodified $uid
|
||||||
sedrv=$((sedrv + $?))
|
sedrv=$((sedrv + $?))
|
||||||
if [[ $sedrv -eq 0 ]]; then
|
if [[ $sedrv -eq 0 ]]; then
|
||||||
action "Shifted task #${id} upwards/left."
|
action "Shifted task #${id} upwards/left."
|
||||||
loadtask $file
|
loadtask "$file"
|
||||||
|
|
||||||
showit ${taskparent[$id]} $uid
|
showit ${taskparent[$id]} $uid
|
||||||
|
|
||||||
|
@ -528,18 +528,18 @@ function move_right() { # move_right uid new_parent
|
||||||
rv=0
|
rv=0
|
||||||
|
|
||||||
taskparent[$id]="$newparent"
|
taskparent[$id]="$newparent"
|
||||||
file=$dir/$uid.vcf
|
file="$dir/$uid.vcf"
|
||||||
if [[ -z $newparent ]]; then
|
if [[ -z $newparent ]]; then
|
||||||
sed -i "/^RELATED-TO.*/d" $file
|
sed -i "/^RELATED-TO.*/d" "$file"
|
||||||
sedrv=$?
|
sedrv=$?
|
||||||
else
|
else
|
||||||
if grep -q ^RELATED-TO $file; then
|
if grep -q ^RELATED-TO "$fil"e; then
|
||||||
sed -i "s/^RELATED-TO.*/RELATED-TO;RELTYPE=PARENT:${taskparent[$id]}/" $file
|
sed -i "s/^RELATED-TO.*/RELATED-TO;RELTYPE=PARENT:${taskparent[$id]}/" "$file"
|
||||||
sedrv=$?
|
sedrv=$?
|
||||||
else
|
else
|
||||||
str="END:VTODO"
|
str="END:VTODO"
|
||||||
toadd="RELATED-TO;RELTYPE=PARENT:${taskparent[$id]}"
|
toadd="RELATED-TO;RELTYPE=PARENT:${taskparent[$id]}"
|
||||||
sed -i "/$str/i $toadd\n" $file
|
sed -i "/$str/i $toadd\n" "$file"
|
||||||
sedrv=$?
|
sedrv=$?
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -552,7 +552,7 @@ function move_right() { # move_right uid new_parent
|
||||||
str="underneath #${newparentid} ('${tasksum[$newparentid]}')."
|
str="underneath #${newparentid} ('${tasksum[$newparentid]}')."
|
||||||
fi
|
fi
|
||||||
action "Shifted task #${id} $str"
|
action "Shifted task #${id} $str"
|
||||||
loadtask $file
|
loadtask "$file"
|
||||||
|
|
||||||
showit ${taskparent[$id]} $uid
|
showit ${taskparent[$id]} $uid
|
||||||
|
|
||||||
|
@ -580,15 +580,15 @@ function setnote() { # setnote uid new note goes here
|
||||||
shift
|
shift
|
||||||
newnote="$*"
|
newnote="$*"
|
||||||
|
|
||||||
file=$dir/$uid.vcf
|
file="$dir/$uid.vcf"
|
||||||
|
|
||||||
if grep -q ^DESCRIPTION: $file; then
|
if grep -q ^DESCRIPTION: "$file"; then
|
||||||
sed -i "s/^DESCRIPTION:.*/DESCRIPTION:$newnote/" $file
|
sed -i "s/^DESCRIPTION:.*/DESCRIPTION:$newnote/" "$file"
|
||||||
sedrv=$?
|
sedrv=$?
|
||||||
else
|
else
|
||||||
str="END:VTODO"
|
str="END:VTODO"
|
||||||
toadd="DESCRIPTION:$newnote"
|
toadd="DESCRIPTION:$newnote"
|
||||||
sed -i "/$str/i $toadd\n" $file
|
sed -i "/$str/i $toadd\n" "$file"
|
||||||
sedrv=$?
|
sedrv=$?
|
||||||
fi
|
fi
|
||||||
set_lastmodified $uid
|
set_lastmodified $uid
|
||||||
|
@ -599,7 +599,7 @@ function setnote() { # setnote uid new note goes here
|
||||||
else
|
else
|
||||||
action "Set note of task #${id} to '$newnote'."
|
action "Set note of task #${id} to '$newnote'."
|
||||||
fi
|
fi
|
||||||
loadtask $file
|
loadtask "$file"
|
||||||
rv=0
|
rv=0
|
||||||
else
|
else
|
||||||
error "Failed to set note of task #${id}."
|
error "Failed to set note of task #${id}."
|
||||||
|
@ -622,11 +622,11 @@ function modtag() { # setnote uid add|del new tag goes here
|
||||||
shift
|
shift
|
||||||
arg="$*"
|
arg="$*"
|
||||||
|
|
||||||
file=$dir/$uid.vcf
|
file="$dir/$uid.vcf"
|
||||||
|
|
||||||
if [[ -z $arg ]]; then
|
if [[ -z $arg ]]; then
|
||||||
if [[ $action == "del" ]]; then
|
if [[ $action == "del" ]]; then
|
||||||
sed -i "/^CATEGORIES:/d" $file
|
sed -i "/^CATEGORIES:/d" "$file"
|
||||||
sedrv=$?
|
sedrv=$?
|
||||||
else
|
else
|
||||||
error "No tag specified to add."
|
error "No tag specified to add."
|
||||||
|
@ -646,13 +646,13 @@ function modtag() { # setnote uid add|del new tag goes here
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if grep -q ^CATEGORIES: $file; then
|
if grep -q ^CATEGORIES: "$file"; then
|
||||||
sed -i "s/^CATEGORIES:.*/CATEGORIES:${newcat}/" $file
|
sed -i "s/^CATEGORIES:.*/CATEGORIES:${newcat}/" "$file"
|
||||||
sedrv=$?
|
sedrv=$?
|
||||||
else
|
else
|
||||||
str="END:VTODO"
|
str="END:VTODO"
|
||||||
toadd="CATEGORIES:${newcat}"
|
toadd="CATEGORIES:${newcat}"
|
||||||
sed -i "/$str/i $toadd\n" $file
|
sed -i "/$str/i $toadd\n" "$file"
|
||||||
sedrv=$?
|
sedrv=$?
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -668,7 +668,7 @@ function modtag() { # setnote uid add|del new tag goes here
|
||||||
else
|
else
|
||||||
action "Added tag '$arg' to task #${id}."
|
action "Added tag '$arg' to task #${id}."
|
||||||
fi
|
fi
|
||||||
loadtask $file
|
loadtask "$file"
|
||||||
rv=0
|
rv=0
|
||||||
else
|
else
|
||||||
error "Failed to set/remove tag on task #${id}."
|
error "Failed to set/remove tag on task #${id}."
|
||||||
|
@ -688,15 +688,15 @@ function rename() { # rename uid new name goes here
|
||||||
shift
|
shift
|
||||||
newname="$*"
|
newname="$*"
|
||||||
|
|
||||||
file=$dir/$uid.vcf
|
file="$dir/$uid.vcf"
|
||||||
|
|
||||||
sed -i "s/^SUMMARY:.*/SUMMARY:$newname/" $file
|
sed -i "s/^SUMMARY:.*/SUMMARY:$newname/" "$file"
|
||||||
sedrv=$?
|
sedrv=$?
|
||||||
set_lastmodified $uid
|
set_lastmodified $uid
|
||||||
sedrv=$((sedrv + $?))
|
sedrv=$((sedrv + $?))
|
||||||
if [[ $sedrv -eq 0 ]]; then
|
if [[ $sedrv -eq 0 ]]; then
|
||||||
action "Renamed task #${id} to '$newname'."
|
action "Renamed task #${id} to '$newname'."
|
||||||
loadtask $file
|
loadtask "$file"
|
||||||
rv=0
|
rv=0
|
||||||
else
|
else
|
||||||
error "failed to rename task #${id}."
|
error "failed to rename task #${id}."
|
||||||
|
@ -752,13 +752,13 @@ function fold() {
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
file=$dir/$uid.vcf
|
file="$dir/$uid.vcf"
|
||||||
str="END:VTODO"
|
str="END:VTODO"
|
||||||
if grep -q ^X-OC-HIDESUBTASKS: $file ; then
|
if grep -q ^X-OC-HIDESUBTASKS: "$file" ; then
|
||||||
sed -i "s/X-OC-HIDESUBTASKS:.*/X-OC-HIDESUBTASKS:1/" $file
|
sed -i "s/X-OC-HIDESUBTASKS:.*/X-OC-HIDESUBTASKS:1/" "$file"
|
||||||
sedrv=$?
|
sedrv=$?
|
||||||
else
|
else
|
||||||
sed -i "/$str/i X-OC-HIDESUBTASKS:1" $file
|
sed -i "/$str/i X-OC-HIDESUBTASKS:1" "$file"
|
||||||
sedrv=$?
|
sedrv=$?
|
||||||
fi
|
fi
|
||||||
set_lastmodified $uid
|
set_lastmodified $uid
|
||||||
|
@ -766,7 +766,7 @@ function fold() {
|
||||||
if [[ $sedrv -eq 0 ]]; then
|
if [[ $sedrv -eq 0 ]]; then
|
||||||
action "Folded task #${id}."
|
action "Folded task #${id}."
|
||||||
processed="$processed ${uid} "
|
processed="$processed ${uid} "
|
||||||
loadtask $file
|
loadtask "$file"
|
||||||
rv=0
|
rv=0
|
||||||
else
|
else
|
||||||
failed="$failed ${uid} "
|
failed="$failed ${uid} "
|
||||||
|
@ -796,13 +796,13 @@ function unfold() {
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
file=$dir/$uid.vcf
|
file="$dir/$uid.vcf"
|
||||||
str="END:VTODO"
|
str="END:VTODO"
|
||||||
if grep -q ^X-OC-HIDESUBTASKS: $file ; then
|
if grep -q ^X-OC-HIDESUBTASKS: "$file" ; then
|
||||||
sed -i "s/X-OC-HIDESUBTASKS:.*/X-OC-HIDESUBTASKS:0/" $file
|
sed -i "s/X-OC-HIDESUBTASKS:.*/X-OC-HIDESUBTASKS:0/" "$file"
|
||||||
sedrv=$?
|
sedrv=$?
|
||||||
else
|
else
|
||||||
sed -i "/$str/i X-OC-HIDESUBTASKS:0" $file
|
sed -i "/$str/i X-OC-HIDESUBTASKS:0" "$file"
|
||||||
sedrv=$?
|
sedrv=$?
|
||||||
fi
|
fi
|
||||||
set_lastmodified $uid
|
set_lastmodified $uid
|
||||||
|
@ -810,7 +810,7 @@ function unfold() {
|
||||||
if [[ $sedrv -eq 0 ]]; then
|
if [[ $sedrv -eq 0 ]]; then
|
||||||
action "Unfolded task #${id}."
|
action "Unfolded task #${id}."
|
||||||
processed="$processed ${uid} "
|
processed="$processed ${uid} "
|
||||||
loadtask $file
|
loadtask "$file"
|
||||||
rv=0
|
rv=0
|
||||||
else
|
else
|
||||||
failed="$failed ${uid} "
|
failed="$failed ${uid} "
|
||||||
|
@ -839,15 +839,15 @@ function markdone() {
|
||||||
toadd2="PERCENT-COMPLETE:100"
|
toadd2="PERCENT-COMPLETE:100"
|
||||||
toadd3="COMPLETED:$now"
|
toadd3="COMPLETED:$now"
|
||||||
|
|
||||||
file=$dir/$uid.vcf
|
file="$dir/$uid.vcf"
|
||||||
sed -i "/$str/i $toadd1\n$toadd2\n$toadd3" $file
|
sed -i "/$str/i $toadd1\n$toadd2\n$toadd3" "$file"
|
||||||
sedrv=$?
|
sedrv=$?
|
||||||
set_lastmodified $uid
|
set_lastmodified $uid
|
||||||
sedrv=$((sedrv + $?))
|
sedrv=$((sedrv + $?))
|
||||||
if [[ $sedrv -eq 0 ]]; then
|
if [[ $sedrv -eq 0 ]]; then
|
||||||
action "Marked $noun #${id} as completed."
|
action "Marked $noun #${id} as completed."
|
||||||
processed="$processed ${uid} "
|
processed="$processed ${uid} "
|
||||||
loadtask $file
|
loadtask "$file"
|
||||||
rv=0
|
rv=0
|
||||||
children=$(getchildren $uid)
|
children=$(getchildren $uid)
|
||||||
for childuid in ${children}; do
|
for childuid in ${children}; do
|
||||||
|
@ -867,10 +867,10 @@ function viewtask() {
|
||||||
local uid id file
|
local uid id file
|
||||||
uid=$1
|
uid=$1
|
||||||
id=$(getid $uid)
|
id=$(getid $uid)
|
||||||
file=$dir/$uid.vcf
|
file="$dir/$uid.vcf"
|
||||||
|
|
||||||
action "Viewing task #$id ($file):"
|
action "Viewing task #$id ($file):"
|
||||||
cat $file | sed -e 's/^/ /'
|
cat "$file" | sed -e 's/^/ /'
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -913,9 +913,9 @@ function addtask() {
|
||||||
taskchecked[$thisid]=0
|
taskchecked[$thisid]=0
|
||||||
taskfolded[$thisid]=0
|
taskfolded[$thisid]=0
|
||||||
taskparent[$thisid]=$parentuid
|
taskparent[$thisid]=$parentuid
|
||||||
file=$dir/$uid.vcf
|
file="$dir/$uid.vcf"
|
||||||
now=$(date -u +'%Y%m%dT%H%M%SZ')
|
now=$(date -u +'%Y%m%dT%H%M%SZ')
|
||||||
cat >$file <<EOF
|
cat >"$file" <<EOF
|
||||||
BEGIN:VCALENDAR
|
BEGIN:VCALENDAR
|
||||||
VERSION:2.0
|
VERSION:2.0
|
||||||
PRODID:+//IDN tasks.org//android-111003//EN
|
PRODID:+//IDN tasks.org//android-111003//EN
|
||||||
|
@ -927,9 +927,9 @@ LAST-MODIFIED:$now
|
||||||
SUMMARY:${tasksum[$thisid]}
|
SUMMARY:${tasksum[$thisid]}
|
||||||
EOF
|
EOF
|
||||||
if [[ ! -z ${taskparent[$thisid]} ]]; then
|
if [[ ! -z ${taskparent[$thisid]} ]]; then
|
||||||
echo "RELATED-TO;RELTYPE=PARENT:${taskparent[$thisid]}" >>$file
|
echo "RELATED-TO;RELTYPE=PARENT:${taskparent[$thisid]}" >>"$file"
|
||||||
fi
|
fi
|
||||||
cat >>$file <<EOF2
|
cat >>"$file" <<EOF2
|
||||||
PRIORITY:9
|
PRIORITY:9
|
||||||
X-APPLE-SORT-ORDER:611376630
|
X-APPLE-SORT-ORDER:611376630
|
||||||
X-OC-HIDESUBTASKS:0
|
X-OC-HIDESUBTASKS:0
|
||||||
|
@ -1374,10 +1374,10 @@ VDIRSYNCER=/usr/local/bin/vdirsyncer
|
||||||
DEFAULT_VDS_LOCAL=cal_local
|
DEFAULT_VDS_LOCAL=cal_local
|
||||||
DEFAULT_VDS_REMOTE=cal_remote
|
DEFAULT_VDS_REMOTE=cal_remote
|
||||||
basedir=/Users/rpearce/code/task_cli
|
basedir=/Users/rpearce/code/task_cli
|
||||||
confdir=${HOME}/.task_cli
|
confdir="${HOME}/.task_cli"
|
||||||
allcalsdir=$confdir/allcals # symlink to vdirsyncer/calendar/
|
allcalsdir="$confdir/allcals" # symlink to vdirsyncer/calendar/
|
||||||
defaultcalfile=$confdir/defaultcal
|
defaultcalfile="$confdir/defaultcal"
|
||||||
idfile=$confdir/idmappings
|
idfile="$confdir/idmappings"
|
||||||
nextid=1
|
nextid=1
|
||||||
indent=0
|
indent=0
|
||||||
indentamt=4
|
indentamt=4
|
||||||
|
|
Loading…
Reference in New Issue