Compare commits

...

3 Commits

Author SHA1 Message Date
Yujie Wu
2a65615c7a Added a case for the fixed replace command. 2010-05-08 08:52:59 +08:00
Yujie Wu
d7e194b09d Fixed bug for replace command. 2010-05-08 08:52:59 +08:00
Jared Cordasco
a4ab8a808a Tab fixes. 2010-04-16 06:12:00 +08:00
2 changed files with 25 additions and 20 deletions

View File

@@ -71,6 +71,11 @@ TODO: 4 prioritized (A).
4: (A) collect the eggs
replaced with
4: (A) collect the bread
>>> todo.sh replace 4 collect the eggs
4: (A) collect the bread
replaced with
4: (A) collect the eggs
EOF
test_todo_session 'replace with &' << EOF
>>> todo.sh replace 3 "thrash the hay & thresh the wheat"

40
todo.sh
View File

@@ -262,7 +262,7 @@ cleaninput()
action_regexp="^\(append\|app\|prepend\|prep\|replace\)$"
# Check which action we are being used in as this affects what cleaning we do
if [ `echo $action | grep -c $action_regexp` -eq 1 ]; then
if [ `echo $action | grep -c $action_regexp` -eq 1 ]; then
# These actions use sed and & as the matched string so escape it
input=`echo $input | sed 's/\&/\\\&/g'`
fi
@@ -772,26 +772,26 @@ case $action in
# Split multiple do's, if comma seperated change to whitespace sepereated
# Loop the 'do' function for each item
for item in `echo $* | tr ',' ' '`; do
[ -z "$item" ] && die "$errmsg"
[[ "$item" = +([0-9]) ]] || die "$errmsg"
[ -z "$item" ] && die "$errmsg"
[[ "$item" = +([0-9]) ]] || die "$errmsg"
todo=$(sed "$item!d" "$TODO_FILE")
[ -z "$todo" ] && die "$item: No such todo."
todo=$(sed "$item!d" "$TODO_FILE")
[ -z "$todo" ] && die "$item: No such todo."
# Check if this item has already been done
if [ `echo $todo | grep -c "^x "` -eq 0 ] ; then
now=`date '+%Y-%m-%d'`
# remove priority once item is done
sed -i.bak $item"s/^(.) //" "$TODO_FILE"
sed -i.bak $item"s|^|&x $now |" "$TODO_FILE"
[ $TODOTXT_VERBOSE -gt 0 ] && {
newtodo=$(sed "$item!d" "$TODO_FILE")
echo "$item: $newtodo"
echo "TODO: $item marked as done."
}
else
echo "$item is already marked done"
fi
# Check if this item has already been done
if [ `echo $todo | grep -c "^x "` -eq 0 ] ; then
now=`date '+%Y-%m-%d'`
# remove priority once item is done
sed -i.bak $item"s/^(.) //" "$TODO_FILE"
sed -i.bak $item"s|^|&x $now |" "$TODO_FILE"
[ $TODOTXT_VERBOSE -gt 0 ] && {
newtodo=$(sed "$item!d" "$TODO_FILE")
echo "$item: $newtodo"
echo "TODO: $item marked as done."
}
else
echo "$item is already marked done"
fi
done
if [ $TODOTXT_AUTO_ARCHIVE = 1 ]; then
@@ -1011,7 +1011,7 @@ note: PRIORITY must be anywhere from A to Z."
if [ -z $priority ]; then
sed -i.bak $item" s|^.*|$input|" "$TODO_FILE"
else
sed -i.bak -e "$item s/^(.) //" -e "$item s|^.*|\($priority\) $1|" "$TODO_FILE"
sed -i.bak -e "$item s/^(.) //" -e "$item s|^.*|\($priority\) $input|" "$TODO_FILE"
fi
[ $TODOTXT_VERBOSE -gt 0 ] && {
NEWTODO=$(head -$item "$TODO_FILE" | tail -1)