1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-22 16:41:12 +02:00

43177: _grep: support bzgrep, and add a few options for macOS

This commit is contained in:
Jun-ichi Takimoto 2018-07-18 00:38:10 +09:00
parent 14fe9799ff
commit 73a3ad345c
2 changed files with 19 additions and 8 deletions

View file

@ -1,3 +1,8 @@
2018-07-18 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
* 43177: Completion/Unix/Command/_grep: support bzgrep, and add
a few options for macOS.
2018-07-17 Peter Stephenson <p.stephenson@samsung.com> 2018-07-17 Peter Stephenson <p.stephenson@samsung.com>
* unposted: Doc/Makefile.in: remove ftp_sites.yo. * unposted: Doc/Makefile.in: remove ftp_sites.yo.

View file

@ -1,4 +1,4 @@
#compdef grep egrep fgrep bsdgrep zgrep zegrep zfgrep ggrep gegrep gfgrep gzgrep gzegrep gzfgrep -value-,GREP_OPTIONS,-default- #compdef grep egrep fgrep bsdgrep zgrep zegrep zfgrep ggrep gegrep gfgrep gzgrep gzegrep gzfgrep bzgrep bzegrep bzfgrep -value-,GREP_OPTIONS,-default-
local arguments matchers command variant local arguments matchers command variant
@ -11,13 +11,15 @@ else
arguments=( '(-e --regexp -f --file)1: :_guard "^-*" pattern' ) arguments=( '(-e --regexp -f --file)1: :_guard "^-*" pattern' )
if [[ $service = z* ]]; then if [[ $service = z* ]]; then
arguments+=( '*:files:_files -g "*.gz(-.)"' ) arguments+=( '*:files:_files -g "*.gz(-.)"' )
elif [[ $service = bz* ]]; then
arguments+=( '*:files:_files -g "*.bz2(-.)"' )
else else
arguments+=( '*:files:_files' ) arguments+=( '*:files:_files' )
fi fi
command="$words[1]" command="$words[1]"
fi fi
if [[ $service != (|g)(|z)[ef]grep ]]; then if [[ $service != (|g|z|gz|bz)[ef]grep ]]; then
matchers='(--extended-regexp --fixed-strings --basic-regexp --perl-regexp -E -F -G -P)' matchers='(--extended-regexp --fixed-strings --basic-regexp --perl-regexp -E -F -G -P)'
arguments+=( arguments+=(
$matchers{--extended-regexp,-E}'[use extended regular expression]' $matchers{--extended-regexp,-E}'[use extended regular expression]'
@ -66,7 +68,7 @@ arguments+=(
_pick_variant -r variant -c "$command" gnu=gnu gpl2=2.5.1 unix --version _pick_variant -r variant -c "$command" gnu=gnu gpl2=2.5.1 unix --version
case $variant:$OSTYPE in case $variant:$OSTYPE in
(gnu:*|gpl2:freebsd*)) (gnu:*|gpl2:freebsd*))
[[ $service != (|g)(|z)[ef]grep ]] && arguments+=( [[ $service != (|g|z|gz|bz)[ef]grep ]] && arguments+=(
$matchers{--perl-regexp,-P}'[use perl regular expression]' $matchers{--perl-regexp,-P}'[use perl regular expression]'
) )
;| ;|
@ -76,17 +78,21 @@ case $variant:$OSTYPE in
'(-z --null-data)'{-z,--null-data}'[input data separated by 0 byte, not newline]' '(-z --null-data)'{-z,--null-data}'[input data separated by 0 byte, not newline]'
) )
;| ;|
gpl2:freebsd*)
arguments+=(
'(--null --no-filename -h)--null[print 0 byte after each filename]'
)
;|
gpl2:(freebsd|darwin)*) gpl2:(freebsd|darwin)*)
arguments+=( arguments+=(
'(--null --no-filename -h)--null[print 0 byte after each filename]'
'(-Z --decompress -J --bz2decompress)'{-J,--bz2decompress}"[decompress bzip2'ed input before searching]" '(-Z --decompress -J --bz2decompress)'{-J,--bz2decompress}"[decompress bzip2'ed input before searching]"
'(-Z --decompress -J --bz2decompress)'{-Z,--decompress}"[decompress gzip'ed input before searching]" '(-Z --decompress -J --bz2decompress)'{-Z,--decompress}"[decompress gzip'ed input before searching]"
) )
;| ;|
gpl2:darwin*)
arguments+=(
'(-p -S)-O[follow symlinks on the command line]'
'(-O -S)-p[do not follow symlinks]'
'(-O -p)-S[follow all symlinks]'
'*--include-dir=[only search directories matching specified pattern]:directory pattern'
)
;|
(gnu:*|gpl2:netbsd*)) (gnu:*|gpl2:netbsd*))
arguments+=( arguments+=(
'(--null -Z --no-filename -h)'{--null,-Z}'[print 0 byte after each filename]' '(--null -Z --no-filename -h)'{--null,-Z}'[print 0 byte after each filename]'