Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Completion: Minor improvements to _comm and _sed
- X-seq: zsh-workers 43043
- From: dana <dana@xxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: [PATCH] Completion: Minor improvements to _comm and _sed
- Date: Sun, 17 Jun 2018 16:49:18 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana-is.20150623.gappssmtp.com; s=20150623; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=yMt9XD6OyF+XF+YePl/EivkuD0H6vT7L4JG44EKLgM8=; b=ch+i0gWb4TCoLIeirp4+QAJwL3NbDnNeIo9XS41gN4PWRzWLKGyKWHU6hk4nfo7ojn sNdZcPHQ+CaIvBDZQVPUA/JjkNpRd6/ko5iFAgZGKE6hkgaOCni1k4pNMO1NP6IieCj8 YclfRYnBlg3om+0IZma8ZUDbenS7+3+g1MMbAdy0r+XENTDydgEidOd+kegJWACJ2RcW yYxLTI8C1f1rx11SNPrzGT0Obq5LO99zIZfYMDMcyISKYvtWecPENKmBz4YM6nvknpD4 9R6wnlSvuVOB/FptsCscFXBlVp10H2v2p1dk3jZGHE7cP9yO3uK4Ll2tkfOfneZRWZR3 9s8g==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
Some minor improvements to _comm and _sed:
* Call _arguments with -S and (where appropriate) -A
* Fix some option-spec syntax errors in _comm
* Add some missing options to _comm
* Don't complete `sed -r` on Darwin
* Change all option specs in _sed to use -o+/--opt= instead of -o-/--opt=- (i'm
not aware of any platform where the latter is appropriate)
dana
diff --git a/Completion/Unix/Command/_comm b/Completion/Unix/Command/_comm
index d1d835f6a..f8c535a44 100644
--- a/Completion/Unix/Command/_comm
+++ b/Completion/Unix/Command/_comm
@@ -1,6 +1,6 @@
#compdef comm gcomm
-local -a args
+local -a args aopts=( -A '-*' )
args=(
'-1[suppress lines unique to first file]'
@@ -11,10 +11,13 @@ args=(
)
if _pick_variant gnu=GNU unix --version; then
+ aopts=( )
args+=(
'(--nocheck-order)--check-order[check input is correctly sorted]'
"(--check-order)--nocheck-order[don't check input is correctly sorted]"
- '--output-delimiter=:delimiter'
+ '--output-delimiter=[specify column delimiter]:delimiter'
+ '--total[display summary]'
+ '(-z --zero-terminated)'{-z,--zero-terminated}'[use NUL as line delimiter]'
'(- : *)--version[display version information]'
'(- : *)--help[display help information]'
)
@@ -24,4 +27,4 @@ elif [[ $OSTYPE = (openbsd|netbsd)* ]]; then
args+=( '-f[case insensitive comparison of lines]' )
fi
-_arguments -s $args
+_arguments -s -S $aopts : $args
diff --git a/Completion/Unix/Command/_sed b/Completion/Unix/Command/_sed
index 15b92a634..80218051b 100644
--- a/Completion/Unix/Command/_sed
+++ b/Completion/Unix/Command/_sed
@@ -1,11 +1,12 @@
#compdef sed gsed psed s2p
-local args inplace extended
+local inplace extended
+local -a args aopts=( -A '-*' )
args=(
'(-n --quiet --silent)'{-n,--quiet,--silent}'[suppress automatic printing of pattern space]'
- '(1)*'{-e,--expression=-}'[specify sed commands to run]:sed script'
- '(1)*'{-f,--file=-}'[add contents of file to commands to run]:file:_files'
+ '(1)*'{-e+,--expression=}'[specify sed commands to run]:sed script'
+ '(1)*'{-f+,--file=}'[add contents of file to commands to run]: :_files'
'(-e)1: :_guard "^-*" sed script'
'*:input file:_files'
)
@@ -18,11 +19,12 @@ if [[ $service = (psed|s2p) ]]; then
'-a[delay opening files listed with w function]'
)
elif _pick_variant gnu=GNU unix --version; then
+ aopts=( )
args+=(
'--follow-symlinks[follow symlinks when processing in place]'
- '(-i --in-place)'{-i-,--in-place=-}$inplace
+ '(-i --in-place)'{-i+,--in-place=}$inplace
'(-c --copy)'{-c,--copy}'[copy instead of rename when shuffling files in in-place mode]'
- '(-l --line-length)'{-l,--line-length=-}'[specify line-wrap length for the l command]'
+ '(-l --line-length)'{-l+,--line-length=}'[specify line-wrap length for the l command]'
'(-r)--posix[disable GNU extensions]'
'(-E -r --regexp-extended)'{-E,-r,--regexp-extended}$extended
'(-s --separate)'{-s,--separate}'[consider files separately instead of as a combined stream]'
@@ -37,20 +39,21 @@ else
case $OSTYPE in
openbsd*|freebsd*|netbsd*|darwin*|dragonfly*)
args+=(
- '(-r -E)'{-r,-E}$extended
+ '(-r -E)'-E$extended
'-a[delay opening files listed with w function]'
)
;|
- darwin*|freebsd*|netbsd*|openbsd*) args+=( '-i'$inplace ) ;|
+ openbsd*|freebsd*|netbsd*|dragonfly*) args+=( '(-r -E)'-r$extended ) ;|
+ darwin*|freebsd*|netbsd*|openbsd*) args+=( '-i+'$inplace ) ;|
darwin*|freebsd*|netbsd*) args+=( '-l[make output line buffered]' ) ;|
freebsd*) args+=( '-u[disable data buffering]' ) ;|
freebsd*|netbsd*)
args+=(
- '-I[edit files in-place, treating all files as a single input stream]::suffix for backup'
+ '-I+[edit files in-place, treating all files as a single input stream]::suffix for backup'
)
;;
openbsd*) args+=( '-u[make output line buffered]' ) ;;
esac
fi
-_arguments -s "$args[@]"
+_arguments -s -S $aopts : "$args[@]"
Messages sorted by:
Reverse Date,
Date,
Thread,
Author