about summary refs log tree commit diff
path: root/Completion/Unix/Command/_grep
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Unix/Command/_grep')
-rw-r--r--Completion/Unix/Command/_grep39
1 files changed, 28 insertions, 11 deletions
diff --git a/Completion/Unix/Command/_grep b/Completion/Unix/Command/_grep
index 81516b08a..2dcbff4a3 100644
--- a/Completion/Unix/Command/_grep
+++ b/Completion/Unix/Command/_grep
@@ -1,6 +1,7 @@
-#compdef grep egrep fgrep bsdgrep zgrep zegrep zfgrep ggrep gegrep gfgrep gzgrep gzegrep gzfgrep bzgrep bzegrep bzfgrep -value-,GREP_OPTIONS,-default-
+#compdef grep egrep fgrep bsdgrep rgrep zgrep zegrep zfgrep ggrep gegrep gfgrep gzgrep gzegrep gzfgrep bzgrep bzegrep bzfgrep -value-,GREP_OPTIONS,-default-
 
-local arguments matchers command variant
+local command variant
+local -a arguments matchers
 
 if [[ $service = *GREP_OPT* ]]; then
   compset -q
@@ -27,6 +28,10 @@ if [[ $service != (|g|z|gz|bz)[ef]grep ]]; then
     $matchers{--basic-regexp,-G}'[use basic regular expression]'
   )
 fi
+[[ $service = rgrep ]] || arguments+=(
+  '(--directories -d -r --recursive)'{--directories=,-d+}'[specify handling of directories]:action on directory:(read skip recurse)'
+  '(--recursive -r --dereference-recursive -R -d --directories)'{--recursive,-r}'[recurse subdirectories]'
+)
 
 arguments+=(
   '(--after-context -A)'{--after-context=,-A+}'[specify lines of trailing context]:lines'
@@ -37,7 +42,6 @@ arguments+=(
   '(--byte-offset -b -c)'{--byte-offset,-b}'[print the byte offset with output lines]'
   '(--text -a -I)--binary-files=[specify type to assume for binary files]:file type:(binary without-match text)'
   '(--count -c --byte-offset -b --line-number -n)'{--count,-c}'[only print a count of matching lines]'
-  '(--directories -d -r --recursive)'{--directories=,-d+}'[specify handling of directories]:action on directory:(read skip recurse)'
   '(--devices -D)'{--devices=,-D+}'[specify handling of devices, FIFOs and sockets]:action on device:(read skip)'
   '(1)*'{--regexp=,-e+}'[specify pattern]:pattern'
   '(1)*'{--file=,-f+}'[specify pattern file]:file:_files'
@@ -53,11 +57,10 @@ arguments+=(
   '(--line-number -n -c)'{--line-number,-n}'[prefix output with line numbers]'
   '(--only-matching -o --files-with-matches -l --files-without-match -L)'{--only-matching,-o}'[show only matching part of line]'
   '(--quiet --silent -q)'{--quiet,--silent,-q}'[suppress normal output]'
-  '(--recursive -r --dereference-recursive -R -d --directories)'{--recursive,-r}'[recurse subdirectories]'
   '*--include=[examine files matching specified pattern]:file pattern'
   '*--exclude=[skip files matching specified pattern]:file pattern'
   '*--exclude-dir=[skip directories matching specified pattern]:directory pattern'
-  '(--no-messages -s)'{--no-messages,-s}'[suppress messages about unreadable]'
+  '(--no-messages -s)'{--no-messages,-s}'[suppress messages about unreadable or non-existent files]'
   '(--version -V)'{--version,-V}'[display version info]'
   '(--invert-match -v)'{--invert-match,-v}'[select non-matching lines]'
   '(--word-regexp -w --line-regexp -x)'{--word-regexp,-w}'[force pattern to match only whole words]'
@@ -72,6 +75,12 @@ case $variant:$OSTYPE in
       $matchers{--perl-regexp,-P}'[use perl regular expression]'
     )
   ;|
+  *:openbsd*|unix:freebsd*)
+    arguments=( # argument to context is optional and after = only
+      ${arguments:#((#s)|*\))-(C|-context)*}
+      '(--context -C)'{--context=-,-C-}'[specify lines of context]::lines'
+    )
+  ;|
   (gnu:*|gpl2:(free|net)bsd*))
     arguments+=(
       '*--exclude-from=[skip files matching pattern in specified file]:file:_files'
@@ -85,15 +94,15 @@ case $variant:$OSTYPE in
       '(-Z --decompress -J --bz2decompress)'{-Z,--decompress}"[decompress gzip'ed input before searching]"
     )
   ;|
-  gpl2:darwin*)
+  (gpl2:darwin*|unix:freebsd*))
     arguments+=(
-      '(-p -S)-O[follow symlinks on the command line]'
-      '(-O -S)-p[do not follow symlinks]'
-      '(-O -p)-S[follow all symlinks]'
+      '(-p -S)-O[recurse symlinks on the command line]'
+      "!(-O -S)-p[don't recurse symlinks]"
+      '(-O -p)-S[recurse all symlinks]'
       '*--include-dir=[only search directories matching specified pattern]:directory pattern'
     )
   ;|
-  (gnu:*|gpl2:netbsd*))
+  (gnu:*|gpl2:netbsd*|unix:freebsd*))
     arguments+=(
       '(--null -Z --no-filename -h)'{--null,-Z}'[print 0 byte after each filename]'
     )
@@ -106,6 +115,15 @@ case $variant:$OSTYPE in
       '(--recursive -r --dereference-recursive -R -d --directories)'{--dereference-recursive,-R}'[recurse subdirectories, following symlinks]'
     )
   ;;
+  unix:freebsd*)
+    arguments+=(
+      '!(-U --binary --binary-files)'{-U,--binary}
+      '--mmap[use mmap(2) instead of read(2) to read input]'
+    )
+    [[ $service = rgrep ]] || arguments+=(
+      '(--recursive -r -d --directories)-R[recurse subdirectories]'
+    )
+  ;;
   gpl2:*) arguments=( ${${arguments:#*\)-r}/\)-r/\)-R} ) ;;
   *:openbsd*)
     arguments=(
@@ -122,4 +140,3 @@ case $variant:$OSTYPE in
 esac
 
 _arguments -S -s $arguments[@]
-