From a894327f9aa389e5222c45d7d0ee0b2644883797 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Wed, 4 Oct 2023 14:51:53 +0200 Subject: xlocate: error when no pattern is given --- xlocate | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'xlocate') diff --git a/xlocate b/xlocate index 7c0b2b8..8dd3e96 100755 --- a/xlocate +++ b/xlocate @@ -72,12 +72,13 @@ usage() { echo "Usage: xlocate [-g | -S | [-EFGPiw] PATTERN]" >&2 } +GOT_E= while getopts gSEFGPiwe:h flag; do case $flag in g) UPDATE=1 ;; S) SYNC=1 ;; [EFGPiw]) GREP_FLAGS="$GREP_FLAGS -$flag" ;; - e) GREP_FLAGS="$GREP_FLAGS -e $OPTARG" ;; + e) GREP_FLAGS="$GREP_FLAGS -e $OPTARG"; GOT_E=true ;; h) usage; exit 0 ;; ?) usage; exit 1 ;; esac @@ -91,7 +92,7 @@ if [ -n "$UPDATE" ]; then elif [ -n "$SYNC" ]; then xsyncgit exit $? -elif [ $# = 0 ]; then +elif [ $# = 0 ] && [ -z "$GOT_E" ]; then usage exit 1 fi -- cgit 1.4.1