From 55a085a71f84a26b57b40a573d9d5953dde5742a Mon Sep 17 00:00:00 2001 From: Jon-William Lewis Date: Fri, 2 Sep 2016 22:12:04 -0500 Subject: [PATCH] Fixed a bug where notes would not be created if the notebook didn't exist. Added "No notes" message to list function --- src/libSNS.src.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/libSNS.src.sh b/src/libSNS.src.sh index e970085..a0f240d 100644 --- a/src/libSNS.src.sh +++ b/src/libSNS.src.sh @@ -31,7 +31,9 @@ function create(){ # If the note's notebook/section does not exist, # create the appropriate folders. - mkdir -p "$NOTES_DIR"/"$(dirname "$FILE")" + if [ ! -d "$(dirname $FILE)" ]; then + mkdir -p "$(dirname $FILE)" + fi # Write the standard note header if [ "$ENCRYPTION" == "TRUE" ]; then @@ -159,9 +161,14 @@ function list(){ if [ ! "$NOTEBOOK" ]; then NOTEBOOK="."; fi cd "$NOTES_DIR" 2>/dev/null || exit 0 - find "$NOTEBOOK" -type f -name "*$EXT" 2>/dev/null || exit 0 | while read file; do - printf "%s\n" "${file%.*}" - done + NOTES=$(find "$NOTEBOOK" -type f -name "*$EXT" 2>/dev/null) + if [ "${NOTES[@]}" ]; then + for file in "${NOTES[@]}"; do + printf "%s\n" "${file%.*}" + done + else + echo "No notes found." + fi }