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.
This commit is contained in:
14
todo.sh
14
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
|
||||
|
||||
Reference in New Issue
Block a user