Skip to content

Commit

Permalink
Make sure we correctly open multiple piped files
Browse files Browse the repository at this point in the history
  • Loading branch information
pimterry committed Dec 1, 2016
1 parent 62e4347 commit 236bfc8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions notes
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ new_note() {

open_something() {
if [[ -p /dev/stdin ]]; then
read note_names
read -d'\n' note_names
while read note_name; do
open_note "$note_name"
done <<< $note_names
done <<< "$note_names"
else
open $notes_dir
fi
Expand Down
11 changes: 11 additions & 0 deletions test/test-open.bats
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,15 @@ notes="./notes"

assert_success
assert_output "Editing $NOTES_DIRECTORY/note.md"
}

@test "Opens multiple files passed by pipe if provided" {
touch $NOTES_DIRECTORY/note.md
touch $NOTES_DIRECTORY/note2.md

run bash -c "$notes find | $notes open"

assert_success
assert_line "Editing $NOTES_DIRECTORY/note.md"
assert_line "Editing $NOTES_DIRECTORY/note2.md"
}

0 comments on commit 236bfc8

Please sign in to comment.