Skip to content

Commit 3e7bfee

Browse files
authored
Merge pull request #6 from trengrj/check-editor
Test if $EDITOR set, fail if no editor can be found.
2 parents e13b18d + 49654ac commit 3e7bfee

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
@@ -69,6 +69,10 @@ open_note() {
6969
if [ ! -f "$note_path" ]; then
7070
note_path="$notes_dir/$note_path"
7171
fi
72+
if [ -z "$EDITOR" ]; then
73+
printf "Please set \$EDITOR to edit notes\n"
74+
exit 1
75+
fi
7276

7377
$EDITOR "$note_path" < /dev/tty
7478
}

test/test-open.bats

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

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

0 commit comments

Comments
 (0)