From 0f3d43da61639eda331b1fcaf279bb50ed6f273e Mon Sep 17 00:00:00 2001 From: William Melody Date: Thu, 27 Jun 2024 15:51:10 -0700 Subject: [PATCH] Use separate arguments for `grep` and `git grep` with `--tags`. refs gh-324 --- nb | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/nb b/nb index dde25805..329d0f87 100755 --- a/nb +++ b/nb @@ -16980,13 +16980,26 @@ _search() { _use_git_grep=1 fi - local _grep_arguments=( - "-P" - "-I" - "--ignore-case" - "--only-matching" - -e '(^|\s)#[A-Za-z0-9_-]+' - ) + if ((_use_git_grep)) + then + local _grep_arguments=( + "-P" + "-I" + "--ignore-case" + "--only-matching" + -e '(^|[[:space:]])#[A-Za-z0-9_-]+' + ) + else + local _grep_arguments=( + "--extended-regexp" + "-I" + "--ignore-case" + "--only-matching" + -e '[[:space:]]#[A-Za-z0-9_-]+' + -e '^#[A-Za-z0-9_-]+' + ) + fi + { local __target_path= for __target_path in "${_target_paths[@]:-}"