From 49654ac696197c4a637a8a5c91be2e11e128b521 Mon Sep 17 00:00:00 2001 From: John Trengrove Date: Fri, 2 Dec 2016 20:15:39 +1100 Subject: [PATCH] test if EDITOR set --- notes | 4 ++++ test/test-open.bats | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/notes b/notes index 881ca70..8840d35 100755 --- a/notes +++ b/notes @@ -67,6 +67,10 @@ open_note() { if [ ! -f "$note_path" ]; then note_path="$notes_dir/$note_path" fi + if [ -z "$EDITOR" ]; then + printf "Please set \$EDITOR to edit notes\n" + exit 1 + fi $EDITOR "$note_path" < /dev/tty } diff --git a/test/test-open.bats b/test/test-open.bats index 079d324..a0fb26c 100755 --- a/test/test-open.bats +++ b/test/test-open.bats @@ -28,6 +28,13 @@ notes="./notes" assert_output "Opening $HOME/notes" } +@test "Exits if EDITOR not configured" { + unset EDITOR + run $notes open test + + assert_failure +} + @test "Opens the configured notes directory if set" { run $notes open