ttscoff / QuickQuestion

A simple, text-based system for building an easily-searchable knowlegebase on OS X. CLI, LaunchBar and Alfred included.
http://brettterpstra.com/forget-about-it-or-not/
MIT License
193 stars 29 forks source link

Add explicit trailing slash when saving question #1

Closed andrewsardone closed 13 years ago

andrewsardone commented 13 years ago

If the trailing slash is omitted from the NOTESDIR declaration, QuickQuestion behaves a little unexpectedly. A note is written one directory up from where you expect, with the last NOTESDIR component included in the prefix.

For example, before the change:

NOTESDIR="/path/to/some/dir"
NOTESEXT="txt"
NOTESPRE="qq"
# ...
qq -a "question" "answer"
ls /path/to/some
# dirqq question.txt

After the change:

NOTESDIR="/path/to/some/dir"
NOTESEXT="txt"
NOTESPRE="qq"
# ...
qq -a "question" "answer"
ls /path/to/some/dir
# qq question.txt

If NOTESDIR itself includes a trailing slash, everything still works as before.

Admittedly this is for saving the user from himself.

andrewsardone commented 13 years ago

Also, note that, currently, if the trailing slash is omitted from NOTESDIR, searching for a question's answer won't return anything – the mdfind is restricted to NOTESDIR and answers are being saved one directory up.

ttscoff commented 13 years ago

I've fixed this with:

 NOTESDIR=`echo $NOTESDIR|sed -e '/\/$/! s/$/\//'`

after the config section. That will force a trailing slash if omitted, but won't break it if you do use one in the config settings.