Improved 'move' command.
- Removed (accidental) printing of the task (without leading ITEM#) when checking for existence of the task; using empty check of task text as done elsewhere. - Simplified error handling and using die() for proper exit code. - Aligned verbose move message with the verbose output of other commands.
This commit is contained in:
21
todo.sh
21
todo.sh
@@ -957,10 +957,11 @@ case $action in
|
|||||||
|
|
||||||
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||||
|
|
||||||
if [ -f "$src" ]; then
|
[ -f "$src" ] || die "TODO: Source file $src does not exist."
|
||||||
if [ -f "$dest" ]; then
|
[ -f "$dest" ] || die "TODO: Destination file $dest does not exist."
|
||||||
if sed -ne "$item p" "$src" | grep "^."; then
|
|
||||||
MOVEME=$(sed "$item!d" "$src")
|
MOVEME=$(sed "$item!d" "$src")
|
||||||
|
[ -z "$MOVEME" ] && die "$item: No such item in $src."
|
||||||
if [ $TODOTXT_FORCE = 0 ]; then
|
if [ $TODOTXT_FORCE = 0 ]; then
|
||||||
echo "Move '$MOVEME' from $src to $dest? (y/n)"
|
echo "Move '$MOVEME' from $src to $dest? (y/n)"
|
||||||
read ANSWER
|
read ANSWER
|
||||||
@@ -977,19 +978,13 @@ case $action in
|
|||||||
fi
|
fi
|
||||||
echo "$MOVEME" >> "$dest"
|
echo "$MOVEME" >> "$dest"
|
||||||
|
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: '$MOVEME' moved from '$src' to '$dest'."
|
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||||
|
echo "$item: $MOVEME"
|
||||||
|
echo "TODO: $item moved from '$src' to '$dest'."
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "TODO: No tasks moved."
|
echo "TODO: No tasks moved."
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
echo "$item: No such item in $src."
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "TODO: Destination file $dest does not exist."
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "TODO: Source file $src does not exist."
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"prepend" | "prep" )
|
"prepend" | "prep" )
|
||||||
|
|||||||
Reference in New Issue
Block a user