Skip to content

Commit 49654ac

Browse files
committed
test if EDITOR set
1 parent be7d1f7 commit 49654ac

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

notes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ open_note() {
6767
if [ ! -f "$note_path" ]; then
6868
note_path="$notes_dir/$note_path"
6969
fi
70+
if [ -z "$EDITOR" ]; then
71+
printf "Please set \$EDITOR to edit notes\n"
72+
exit 1
73+
fi
7074

7175
$EDITOR "$note_path" < /dev/tty
7276
}

test/test-open.bats

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ notes="./notes"
2828
assert_output "Opening $HOME/notes"
2929
}
3030

31+
@test "Exits if EDITOR not configured" {
32+
unset EDITOR
33+
run $notes open test
34+
35+
assert_failure
36+
}
37+
3138
@test "Opens the configured notes directory if set" {
3239
run $notes open
3340

0 commit comments

Comments
 (0)