From f383da4a456ad64cf0a2f26f0f1a98933064cc8e Mon Sep 17 00:00:00 2001 From: Piraty Date: Tue, 3 Oct 2023 00:13:45 +0200 Subject: xlocate: pass -e flag to git grep 5edebea ("xlocate: don't mark anything starting with a hyphen as ...") added `--` so passing useful options like `--ignore-case` became impossible. 429db43 ("xlocate: add ability to pass certain flags to git grep") made an attempt to fix this by using a whitelist, but didn't fix the leading-dash usecase. If searching for pattern starting with dash, use xlocate -e '-foo' This reverts commit 5edebea0a738117dde41077cd23756e79f4417e7 --- xlocate | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'xlocate') diff --git a/xlocate b/xlocate index ee4d33f..5892f55 100755 --- a/xlocate +++ b/xlocate @@ -72,11 +72,12 @@ usage() { echo "Usage: xlocate [-g | -S | [-EFGPiw] PATTERN]" >&2 } -while getopts gSEFGPiwh flag; do +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" ;; h) usage; exit 0 ;; ?) usage; exit 1 ;; esac @@ -105,7 +106,7 @@ if [ -d "$XLOCATE_GIT" ]; then echo "xlocate: database outdated, please run xlocate -g." >&2 fi fi - $GIT_CMD -c grep.lineNumber=false -c grep.column=false --git-dir="$XLOCATE_GIT" grep $GREP_FLAGS -- "$@" @ | + $GIT_CMD -c grep.lineNumber=false -c grep.column=false --git-dir="$XLOCATE_GIT" grep $GREP_FLAGS "$@" @ | sed 's/^@://' | $COLUMN | grep . else echo "xlocate: database not found, please use xlocate -S." >&2 -- cgit 1.4.1