Skip to content

Commit 7109153

Browse files
authored
checks for file with default extension first
1 parent a92cf27 commit 7109153

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

notes

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,13 @@ get_full_note_path() {
174174
local note_path=$1
175175

176176
# first check if file exists
177-
if [ -f "$note_path" ]; then # note path given is good
177+
if [ -f "$note_path" ]; then # note path given is good absolute or relative path
178178
note_path="$note_path"
179-
elif [ -f "$notes_dir/$note_path" ]; then # exists
179+
elif [ -f "$notes_dir/$note_path" ]; then # exists in notes_dir
180180
note_path="$notes_dir/$note_path"
181-
elif echo "$note_path" | grep '[.][A-Za-z]\{1,4\}$' &>/dev/null; then # has a 1-4 letter extension
181+
elif [ -f "$notes_dir/$note_path.$NOTES_EXT" ]; then # note with this name and default extension exists
182+
note_path="$notes_dir/$note_path.$NOTES_EXT"
183+
elif echo "$note_path" | grep '[.][A-Za-z]\{1,4\}$' &>/dev/null; then # given name has a 1-4 letter extension
182184
note_path="$notes_dir/$note_path"
183185
else
184186
if [[ "$note_path" != *.$NOTES_EXT ]]; then

0 commit comments

Comments
 (0)