Skip to content

Commit e3a9eab

Browse files
authored
Merge pull request #73 from pimterry/fix-find-order
Ensure consistent order of find/grep/search results
2 parents c0f05ff + 6982034 commit e3a9eab

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

notes

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ search_filenames_and_contents() {
6262
find_output=$(find "$notes_dir" -type f)
6363
fi
6464
find_result=$?
65-
formatted_output=$(printf "$find_output" | without_notes_dir)
65+
formatted_output=$(printf "$find_output" | without_notes_dir | sort)
6666

6767
if [[ $find_result == 0 && "$formatted_output" ]]; then
6868
printf "$formatted_output\n"
@@ -75,7 +75,7 @@ search_filenames_and_contents() {
7575
find_notes() {
7676
local find_output=$(find "$notes_dir" -ipath "$notes_dir/*$**" -type f 2>&1)
7777
local find_result=$?
78-
local formatted_output=$(printf "$find_output" | without_notes_dir)
78+
local formatted_output=$(printf "$find_output" | without_notes_dir | sort)
7979

8080
if [[ $find_result == 0 && "$formatted_output" ]]; then
8181
printf "$formatted_output\n"
@@ -93,7 +93,7 @@ grep_notes() {
9393

9494
local grep_output=$(grep -r "$notes_dir" -li -e "$*" 2>&1)
9595
local grep_result=$?
96-
local formatted_output=$(printf "$grep_output" | without_notes_dir)
96+
local formatted_output=$(printf "$grep_output" | without_notes_dir | sort)
9797

9898
if [[ $grep_result == 0 && "$formatted_output" ]]; then
9999
printf "$formatted_output\n"

test/test-cat.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ notes="./notes"
5656
}
5757

5858
@test "Show multiple files passed by pipe from find" {
59-
echo line1 >> "$NOTES_DIRECTORY/note.md"
59+
echo line1 >> "$NOTES_DIRECTORY/note1.md"
6060
echo line2 >> "$NOTES_DIRECTORY/note2.md"
6161

6262
run bash -c "$notes find | $notes cat"

0 commit comments

Comments
 (0)