From 550fcb6248cc60197ce1417cb2960a24851cdceb Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Thu, 13 Jan 2022 19:54:24 +0000 Subject: handles command line arguments better --- grepjournal | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/grepjournal b/grepjournal index 0e2e87e..a6194a7 100755 --- a/grepjournal +++ b/grepjournal @@ -6,10 +6,16 @@ # [[ -z "$2" ]] && [[ -n "$1" ]] && searchterm="$1" # [[ -n "$2" ]] && [[ -n "$1" ]] && searchterm="$1" && flag="$2" +[[ $# -eq 0 ]] && echo "Do grepnotes -h"; exit 1 + while [[ $# -gt 0 ]]; do if [[ "$1" = "-i" ]]; then flag="-i" shift + elif [[ "$1" = "-h" ]] || [[ "$1" = "--help" ]]; then + echo "Usage: grepjournal [WORD] [-i (case insensitve)] [-h (display this help)]" + echo " Searches for WORD within all files within ~/Notes/journal. Displayed sorted by date." + exit else searchterm=$1 shift -- cgit v1.2.3