Misc. whitespace cleanups.

Single space after colon.
No end-of-line whitespace.
Replace tabs with whitespace.

Signed-off-by: Emil Sit <sit@emilsit.net>

Signed-off-by: Gina Trapani <ginatrapani@gmail.com>
This commit is contained in:
Emil Sit
2009-03-25 10:43:05 +08:00
committed by Gina Trapani
parent 3a0fd43270
commit 5cc988102d

48
todo.sh
View File

@@ -102,7 +102,7 @@ help()
Marks item on line NUMBER as done in todo.txt. Marks item on line NUMBER as done in todo.txt.
help help
Display this help message. Display this help message.
list [TERM...] list [TERM...]
ls [TERM...] ls [TERM...]
@@ -244,7 +244,7 @@ archive()
cp "$TODO_FILE" "$TMP_FILE" cp "$TODO_FILE" "$TMP_FILE"
sed -n 'G; s/\n/&&/; /^\([ -~]*\n\).*\n\1/d; s/\n//; h; P' "$TMP_FILE" > "$TODO_FILE" sed -n 'G; s/\n/&&/; /^\([ -~]*\n\).*\n\1/d; s/\n//; h; P' "$TMP_FILE" > "$TODO_FILE"
#[[ $TODOTXT_VERBOSE -gt 0 ]] && echo "TODO: Duplicate tasks have been removed." #[[ $TODOTXT_VERBOSE -gt 0 ]] && echo "TODO: Duplicate tasks have been removed."
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: $TODO_FILE archived." [ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: $TODO_FILE archived."
cleanup cleanup
} }
@@ -357,7 +357,7 @@ TODO_SH="$0"
export TODO_SH export TODO_SH
# === SANITY CHECKS (thanks Karl!) === # === SANITY CHECKS (thanks Karl!) ===
[ -r "$TODOTXT_CFG_FILE" ] || die "Fatal error: Cannot read configuration file $TODOTXT_CFG_FILE" [ -r "$TODOTXT_CFG_FILE" ] || die "Fatal error: Cannot read configuration file $TODOTXT_CFG_FILE"
. "$TODOTXT_CFG_FILE" . "$TODOTXT_CFG_FILE"
@@ -367,7 +367,7 @@ ACTION=${1:-$TODOTXT_DEFAULT_ACTION}
[ -d "$TODO_DIR" ] || die "Fatal Error: $TODO_DIR is not a directory" [ -d "$TODO_DIR" ] || die "Fatal Error: $TODO_DIR is not a directory"
( cd "$TODO_DIR" ) || die "Fatal Error: Unable to cd to $TODO_DIR" ( cd "$TODO_DIR" ) || die "Fatal Error: Unable to cd to $TODO_DIR"
[ -w "$TMP_FILE" ] || echo -n > "$TMP_FILE" || die "Fatal Error: Unable to write to $TMP_FILE" [ -w "$TMP_FILE" ] || echo -n > "$TMP_FILE" || die "Fatal Error: Unable to write to $TMP_FILE"
[ -f "$TODO_FILE" ] || cp /dev/null "$TODO_FILE" [ -f "$TODO_FILE" ] || cp /dev/null "$TODO_FILE"
[ -f "$DONE_FILE" ] || cp /dev/null "$DONE_FILE" [ -f "$DONE_FILE" ] || cp /dev/null "$DONE_FILE"
[ -f "$REPORT_FILE" ] || cp /dev/null "$REPORT_FILE" [ -f "$REPORT_FILE" ] || cp /dev/null "$REPORT_FILE"
@@ -444,7 +444,7 @@ _list() {
items=$( items=$(
sed = "$src" \ sed = "$src" \
| sed "N; s/^/ /; s/ *\(.\{$PADDING,\}\)\n/\1 /" \ | sed "N; s/^/ /; s/ *\(.\{$PADDING,\}\)\n/\1 /" \
| grep -v "^[0-9]\+ *$" | grep -v "^[0-9]\+ *$"
) )
if [ "${filter_command}" ]; then if [ "${filter_command}" ]; then
filtered_items=$(echo -ne "$items" | eval ${filter_command}) filtered_items=$(echo -ne "$items" | eval ${filter_command})
@@ -486,7 +486,7 @@ _list() {
fi fi
if [ $TODOTXT_VERBOSE -gt 1 ] if [ $TODOTXT_VERBOSE -gt 1 ]
then then
echo "TODO DEBUG: Filter Command was: ${filter_command:-cat}" echo "TODO DEBUG: Filter Command was: ${filter_command:-cat}"
fi fi
} }
@@ -545,7 +545,7 @@ case $action in
TASKNUM=$(sed -n '$ =' "$dest") TASKNUM=$(sed -n '$ =' "$dest")
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: '$input' added to $dest on line $TASKNUM." [ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: '$input' added to $dest on line $TASKNUM."
else else
echo "TODO: Destination file $dest does not exist." echo "TODO: Destination file $dest does not exist."
fi fi
cleanup;; cleanup;;
@@ -556,7 +556,7 @@ case $action in
[ -z "$item" ] && die "$errmsg" [ -z "$item" ] && die "$errmsg"
[[ "$item" = +([0-9]) ]] || die "$errmsg" [[ "$item" = +([0-9]) ]] || die "$errmsg"
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."
if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then
echo -n "Append: " echo -n "Append: "
read input read input
@@ -567,7 +567,7 @@ case $action in
newtodo=$(sed "$item!d" "$TODO_FILE") newtodo=$(sed "$item!d" "$TODO_FILE")
[ $TODOTXT_VERBOSE -gt 0 ] && echo "$item: $newtodo" [ $TODOTXT_VERBOSE -gt 0 ] && echo "$item: $newtodo"
else else
echo "TODO: Error appending task $item." echo "TODO: Error appending task $item."
fi fi
cleanup;; cleanup;;
@@ -600,17 +600,17 @@ case $action in
# leave blank line behind (preserves line numbers) # leave blank line behind (preserves line numbers)
sed -i.bak -e $2"s/^.*//" "$TODO_FILE" sed -i.bak -e $2"s/^.*//" "$TODO_FILE"
fi fi
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: '$DELETEME' deleted." [ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: '$DELETEME' deleted."
cleanup cleanup
else else
echo "TODO: No tasks were deleted." echo "TODO: No tasks were deleted."
fi fi
else else
echo "$item: No such todo." echo "$item: No such todo."
fi fi
else else
sed -i.bak -e $item"s/$3/ /g" "$TODO_FILE" sed -i.bak -e $item"s/$3/ /g" "$TODO_FILE"
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: $3 removed from $item." [ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: $3 removed from $item."
fi ;; fi ;;
"depri" | "dp" ) "depri" | "dp" )
@@ -618,7 +618,7 @@ case $action in
errmsg="usage: $0 depri ITEM#" errmsg="usage: $0 depri ITEM#"
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."
[[ "$item" = +([0-9]) ]] || die "$errmsg" [[ "$item" = +([0-9]) ]] || die "$errmsg"
sed -e $item"s/^(.*) //" "$TODO_FILE" > /dev/null 2>&1 sed -e $item"s/^(.*) //" "$TODO_FILE" > /dev/null 2>&1
@@ -641,7 +641,7 @@ case $action in
[[ "$item" = +([0-9]) ]] || die "$errmsg" [[ "$item" = +([0-9]) ]] || die "$errmsg"
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."
now=`date '+%Y-%m-%d'` now=`date '+%Y-%m-%d'`
# remove priority once item is done # remove priority once item is done
@@ -702,8 +702,8 @@ case $action in
then then
## A priority was specified ## A priority was specified
pri=$( printf "%s\n" "$1" | tr 'a-z' 'A-Z' | grep '^[A-Z]$' ) || { pri=$( printf "%s\n" "$1" | tr 'a-z' 'A-Z' | grep '^[A-Z]$' ) || {
die "usage: $0 listpri PRIORITY die "usage: $0 listpri PRIORITY
note: PRIORITY must a single letter from A to Z." note: PRIORITY must a single letter from A to Z."
} }
else else
## No priority specified; show all priority tasks ## No priority specified; show all priority tasks
@@ -747,16 +747,16 @@ case $action in
fi fi
echo "$MOVEME" >> "$dest" echo "$MOVEME" >> "$dest"
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: '$MOVEME' moved from '$src' to '$dest'." [ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: '$MOVEME' moved from '$src' to '$dest'."
cleanup cleanup
else else
echo "TODO: No tasks moved." echo "TODO: No tasks moved."
fi fi
else else
echo "$item: No such item in $src." echo "$item: No such item in $src."
fi fi
else else
echo "TODO: Destination file $dest does not exist." echo "TODO: Destination file $dest does not exist."
fi fi
else else
echo "TODO: Source file $src does not exist." echo "TODO: Source file $src does not exist."
@@ -771,7 +771,7 @@ case $action in
[[ "$item" = +([0-9]) ]] || die "$errmsg" [[ "$item" = +([0-9]) ]] || die "$errmsg"
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."
if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then
echo -n "Prepend: " echo -n "Prepend: "
@@ -784,7 +784,7 @@ case $action in
newtodo=$(sed "$item!d" "$TODO_FILE") newtodo=$(sed "$item!d" "$TODO_FILE")
[ $TODOTXT_VERBOSE -gt 0 ] && echo "$item: $newtodo" [ $TODOTXT_VERBOSE -gt 0 ] && echo "$item: $newtodo"
else else
echo "TODO: Error prepending task $item." echo "TODO: Error prepending task $item."
fi fi
cleanup;; cleanup;;
@@ -793,7 +793,7 @@ case $action in
newpri=$( printf "%s\n" "$3" | tr 'a-z' 'A-Z' ) newpri=$( printf "%s\n" "$3" | tr 'a-z' 'A-Z' )
errmsg="usage: $0 pri ITEM# PRIORITY errmsg="usage: $0 pri ITEM# PRIORITY
note: PRIORITY must be anywhere from A to Z." note: PRIORITY must be anywhere from A to Z."
[ "$#" -ne 3 ] && die "$errmsg" [ "$#" -ne 3 ] && die "$errmsg"
[[ "$item" = +([0-9]) ]] || die "$errmsg" [[ "$item" = +([0-9]) ]] || die "$errmsg"
@@ -820,7 +820,7 @@ note: PRIORITY must be anywhere from A to Z."
[[ "$item" = +([0-9]) ]] || die "$errmsg" [[ "$item" = +([0-9]) ]] || die "$errmsg"
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."
if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then
echo -n "Replacement: " echo -n "Replacement: "
@@ -850,7 +850,7 @@ note: PRIORITY must be anywhere from A to Z."
TECHO=$(echo $(date +%Y-%m-%d-%T); echo ' '; echo ${TOTAL:-0}; echo ' '; TECHO=$(echo $(date +%Y-%m-%d-%T); echo ' '; echo ${TOTAL:-0}; echo ' ';
echo ${TDONE:-0}) echo ${TDONE:-0})
echo $TECHO >> "$REPORT_FILE" echo $TECHO >> "$REPORT_FILE"
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: Report file updated." [ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: Report file updated."
cat "$REPORT_FILE" cat "$REPORT_FILE"
cleanup;; cleanup;;