File tree 3 files changed +30
-6
lines changed
3 files changed +30
-6
lines changed Original file line number Diff line number Diff line change 2
2
3
3
configured_dir=${NOTES_DIRECTORY%/ } # Remove trailing slashes
4
4
notes_dir=" ${configured_dir:- $HOME / notes} "
5
- escaped_notes_dir=$( printf $notes_dir | sed -e ' s/[]\/$*.^|[]/\\&/g' )
5
+ escaped_notes_dir=" $( printf " $notes_dir " | sed -e ' s/[]\/$*.^|[]/\\&/g' ) "
6
6
7
7
# If no $EDITOR, look for `editor` (symlink on debian/ubuntu/etc)
8
8
if [ -z " $EDITOR " ] && type editor & > /dev/null; then
9
9
EDITOR=editor
10
10
fi
11
11
12
12
without_notes_dir () {
13
- cat | sed -e s/^$escaped_notes_dir //g | sed -E " s/^\/+//g"
13
+ cat | sed -e " s/^$escaped_notes_dir //g" | sed -E " s/^\/+//g"
14
14
}
15
15
16
16
find_notes () {
@@ -46,7 +46,7 @@ grep_notes() {
46
46
47
47
new_note () {
48
48
note_name=" $* "
49
- mkdir -p $( dirname " $notes_dir /$note_name " )
49
+ mkdir -p " $( dirname " $notes_dir /$note_name " ) "
50
50
open_note " $note_name .md"
51
51
}
52
52
@@ -154,7 +154,7 @@ main() {
154
154
esac
155
155
shift
156
156
157
- $cmd $@
157
+ $cmd " $@ "
158
158
ret=$[$ret +$? ]
159
159
exit $ret
160
160
}
Original file line number Diff line number Diff line change @@ -81,4 +81,14 @@ notes="./notes"
81
81
82
82
assert_success
83
83
assert_output " path with spaces/note.md"
84
- }
84
+ }
85
+
86
+ @test " Should find files inside notes directories with spaces" {
87
+ mkdir " $NOTES_DIRECTORY /path with spaces"
88
+ touch " $NOTES_DIRECTORY /path with spaces/note.md"
89
+
90
+ NOTES_DIRECTORY=" $NOTES_DIRECTORY /path with spaces" run $notes find
91
+
92
+ assert_success
93
+ assert_output " note.md"
94
+ }
Original file line number Diff line number Diff line change @@ -41,4 +41,18 @@ notes="./notes"
41
41
42
42
assert_success
43
43
assert_exists " $NOTES_DIRECTORY /note with spaces.md"
44
- }
44
+ }
45
+
46
+ @test " Should create notes within subfolders with spaces" {
47
+ run $notes new " subfolder with spaces/note"
48
+
49
+ assert_success
50
+ assert_exists " $NOTES_DIRECTORY /subfolder with spaces/note.md"
51
+ }
52
+
53
+ @test " Should create notes within note directories with spaces" {
54
+ NOTES_DIRECTORY=" $NOTES_DIRECTORY /notes with spaces" run $notes new " note"
55
+
56
+ assert_success
57
+ assert_exists " $NOTES_DIRECTORY /notes with spaces/note.md"
58
+ }
You can’t perform that action at this time.
0 commit comments