Bug fix: for replace with priority
Checks for priority, removes, does replace then reinserts priority
This commit is contained in:
13
todo.sh
13
todo.sh
@@ -695,6 +695,7 @@ case $action in
|
|||||||
fi
|
fi
|
||||||
cleanup ;;
|
cleanup ;;
|
||||||
|
|
||||||
|
|
||||||
"help" )
|
"help" )
|
||||||
help
|
help
|
||||||
;;
|
;;
|
||||||
@@ -877,6 +878,11 @@ note: PRIORITY must be anywhere from A to Z."
|
|||||||
todo=$(sed "$item!d" "$TODO_FILE")
|
todo=$(sed "$item!d" "$TODO_FILE")
|
||||||
[ -z "$todo" ] && die "$item: No such todo."
|
[ -z "$todo" ] && die "$item: No such todo."
|
||||||
|
|
||||||
|
# Test for then set priority
|
||||||
|
if [ `sed "$item!d" "$TODO_FILE"|grep -c "^(\\w)"` -eq 1 ]; then
|
||||||
|
priority=$(sed "$item!d" "$TODO_FILE" | awk -F '\\(|\\)' '{print $2}')
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then
|
if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then
|
||||||
echo -n "Replacement: "
|
echo -n "Replacement: "
|
||||||
read input
|
read input
|
||||||
@@ -884,7 +890,12 @@ note: PRIORITY must be anywhere from A to Z."
|
|||||||
input=$*
|
input=$*
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sed -i.bak $item" s|^.*|$input|" "$TODO_FILE"
|
# If priority isn't set replace, if it is remove priority, replace then add priority again
|
||||||
|
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"
|
||||||
|
fi
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && NEWTODO=$(head -$item "$TODO_FILE" | tail -1)
|
[ $TODOTXT_VERBOSE -gt 0 ] && NEWTODO=$(head -$item "$TODO_FILE" | tail -1)
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "$item: $todo"
|
[ $TODOTXT_VERBOSE -gt 0 ] && echo "$item: $todo"
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "replaced with"
|
[ $TODOTXT_VERBOSE -gt 0 ] && echo "replaced with"
|
||||||
|
|||||||
Reference in New Issue
Block a user