about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2023-10-04 14:51:53 +0200
committerLeah Neukirchen <leah@vuxu.org>2023-10-04 14:51:53 +0200
commita894327f9aa389e5222c45d7d0ee0b2644883797 (patch)
tree3fa6886d36aeca3b870fd06a7bd5706ecedd4120
parentfe72c02a44d998a757fdface18dd83b959468ddb (diff)
downloadxtools-a894327f9aa389e5222c45d7d0ee0b2644883797.tar.gz
xtools-a894327f9aa389e5222c45d7d0ee0b2644883797.tar.xz
xtools-a894327f9aa389e5222c45d7d0ee0b2644883797.zip
xlocate: error when no pattern is given
-rwxr-xr-xxlocate5
1 files changed, 3 insertions, 2 deletions
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