From 99f8911c8f8dab216bcffcecc68e575a2f774ea7 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Fri, 16 Jul 2010 16:15:45 +0200 Subject: [PATCH] Added fallback for $TODO_DIR/${FILE}.txt. This allows to leave off the .txt file extension in commands like "todo.sh listfile done". Plus: Minor coding style alignment, replaced $1 argument with existing $FILE variable. --- todo.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/todo.sh b/todo.sh index 22eb642..a614cb7 100755 --- a/todo.sh +++ b/todo.sh @@ -560,18 +560,18 @@ _list() { local FILE="$1" ## If the file starts with a "/" use absolute path. Otherwise, ## try to find it in either $TODO_DIR or using a relative path - if [ "${1:0:1}" == / ] - then + if [ "${1:0:1}" == / ]; then ## Absolute path src="$FILE" - elif [ -f "$TODO_DIR/$FILE" ] - then + elif [ -f "$TODO_DIR/$FILE" ]; then ## Path relative to todo.sh directory - src="$TODO_DIR/$1" - elif [ -f "$FILE" ] - then + src="$TODO_DIR/$FILE" + elif [ -f "$FILE" ]; then ## Path relative to current working directory src="$FILE" + elif [ -f "$TODO_DIR/${FILE}.txt" ]; then + ## Path relative to todo.sh directory, missing file extension + src="$TODO_DIR/${FILE}.txt" else die "TODO: File $FILE does not exist." fi