Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: completion updates for OpenBSD 6.6



This updates some completions for changes in OpenBSD 6.6.

Seems they've actually removed old options in date and dhclient. grep
gained a couple. vmctl's argument order has changed. And the biggest
change is in OpenSSH 8.1 (mostly ssh-keygen) so will be applicable
elsewhere.

Oliver

diff --git a/Completion/BSD/Command/_vmctl b/Completion/BSD/Command/_vmctl
index d22657310..873bb5670 100644
--- a/Completion/BSD/Command/_vmctl
+++ b/Completion/BSD/Command/_vmctl
@@ -42,18 +42,14 @@ else
       _vm_names
       ;;
     create)
-      if (( CURRENT == 2 )); then
-	compset -P '(raw|qcow2):' || alts=(
-	  'prefixes:prefix:compadd -S: raw qcow2'
-	)
-	_alternative 'files:path:_files' $alts
-      else
-	shift words; (( CURRENT-- ))
-	_arguments \
-	  '-s+[specify size]:size' \
-          '(-i)-b+[specify base disk]:base image:_files'
-          '(-b)-i+[copy and convert input disk]:disk image:_files'
-      fi
+      compset -P '(raw|qcow2):' || alts=(
+        'prefixes:prefix:compadd -S: raw qcow2'
+      )
+      _arguments \
+        '-s+[specify size]:size' \
+        '(-i)-b+[specify base disk]:base image:_files' \
+        '(-b)-i+[copy and convert input disk]:disk image:_files' \
+        '1:disk: _alternative "files:path:_files" $alts'
       ;;
     load)
       _arguments ':configuration file:_files'
@@ -72,34 +68,25 @@ else
       ))'
       ;;
     start)
-      if (( CURRENT == 2 )); then
-        _vm_names
-      else
-        shift words; (( CURRENT-- ))
-        _arguments -s \
-          '-B+[force system to boot from specified device for this boot]:device:(cdrom disk net)' \
-          '-b+[boot with the specified kernel or BIOS image]:boot image:_files' \
-          '-c[automatically connect to the VM console]' \
-          '*-d+[disk image file]:disk image:_files' \
-          '-i+[number of network interfaces]:number: ' \
-          '-L[add a local network interface]' \
-          '-m+[specify memory size]:memory size (megabytes) [512]' \
-          '-n+[specify switch to attach]: :_vm_switches' \
-          '-r+[specify ISO image file for virtual CD-ROM]:ISO image:_files -g "*.iso(-.)"' \
-	  '-t+[use existing VM as a template]: :_vm_names'
-      fi
+      _arguments -s \
+        '-B+[force system to boot from specified device for this boot]:device:(cdrom disk net)' \
+        '-b+[boot with the specified kernel or BIOS image]:boot image:_files' \
+        '-c[automatically connect to the VM console]' \
+        '*-d+[disk image file]:disk image:_files' \
+        '-i+[number of network interfaces]:number: ' \
+        '-L[add a local network interface]' \
+        '-m+[specify memory size]:memory size (megabytes) [512]' \
+        '-n+[specify switch to attach]: :_vm_switches' \
+        '-r+[specify ISO image file for virtual CD-ROM]:ISO image:_files -g "*.iso(-.)"' \
+        '-t+[use existing VM as a template]: :_vm_names' \
+        '1: :_vm_names'
     ;;
     stop)
-      if (( CURRENT == 2 )); then
-	_alternative \
-	  'all:all:(-a)' \
-	  'virtual-machines: :_vm_names'
-      else
-	shift words; (( CURRENT-- ))
-	_arguments \
-	  '-f[forcefully stop without attempting a graceful shutdown]' \
-	  '-w[wait until the VM has been terminated]'
-      fi
+      _arguments \
+        '(1)-a[stop all running VMs]' \
+        '-f[forcefully stop without attempting a graceful shutdown]' \
+        '-w[wait until the VM has been terminated]' \
+        '(-a)1: :_vm_names'
     ;;
     *)
       _default
diff --git a/Completion/Unix/Command/_date b/Completion/Unix/Command/_date
index 91bd3b5f1..68bd357fb 100644
--- a/Completion/Unix/Command/_date
+++ b/Completion/Unix/Command/_date
@@ -40,9 +40,7 @@ else
     ;|
     freebsd*|dragonfly*|darwin*|openbsd*)
       args+=(
-	'-d+:daylight saving time value'
 	'-f+[use specified format for input]:parsing format:_date_formats:new date'
-	'-t+:minutes west of GMT'
       )
     ;|
     dragonfly*|darwin*|netbsd*|openbsd*)
@@ -62,8 +60,12 @@ else
       )
     ;|
     freebsd*|dragonfly*|darwin*)
-      args+=( "*-v+[adjust and print (but don't set) date]:[+-]value[ymwdHMS]" )
-    ;;
+      args+=(
+	'-d+:daylight saving time value'
+	'-t+:minutes west of GMT'
+	"*-v+[adjust and print (but don't set) date]:[+-]value[ymwdHMS]"
+      )
+    ;|
     freebsd*|dragonfly*)
       args+=( '-R[display in RFC2822 format]' )
     ;|
diff --git a/Completion/Unix/Command/_dhclient b/Completion/Unix/Command/_dhclient
index fe5347bbc..d5ca5b271 100644
--- a/Completion/Unix/Command/_dhclient
+++ b/Completion/Unix/Command/_dhclient
@@ -6,12 +6,12 @@ case $OSTYPE in
   (open|free)bsd*)
     args+=(
       '-c+[specify configuration file]:file:_files'
-      '-l+[specify leases file]:file:_files'
     )
   ;|
   freebsd*)
     args+=(
       '(-d)-b[immediately move to the background]'
+      '-l+[specify leases file]:file:_files'
       '-p+[specify PID file]:file:_files'
       '-u[reject leases with unknown options]'
       '-q[quiet]'
diff --git a/Completion/Unix/Command/_grep b/Completion/Unix/Command/_grep
index d3e1b1a6e..81516b08a 100644
--- a/Completion/Unix/Command/_grep
+++ b/Completion/Unix/Command/_grep
@@ -109,7 +109,7 @@ case $variant:$OSTYPE in
   gpl2:*) arguments=( ${${arguments:#*\)-r}/\)-r/\)-R} ) ;;
   *:openbsd*)
     arguments=(
-      ${(M)arguments:#((#s)|*\))--(context|binary-files|line-buffered)*}
+      ${(M)arguments:#((#s)|*\))--(context|binary-files|line-buffered|label|max-count)*}
       ${${arguments:#((#s)|*\))(\*|)-[d-]*}/\)-r/\)-R}
       "-U[search binary files but don't print them]"
       '-Z[behave as zgrep]'
diff --git a/Completion/Unix/Command/_ssh b/Completion/Unix/Command/_ssh
index df1fe6ca8..0775590e6 100644
--- a/Completion/Unix/Command/_ssh
+++ b/Completion/Unix/Command/_ssh
@@ -3,8 +3,8 @@
 # TODO: sshd, ssh-keysign
 
 _ssh () {
-  local curcontext="$curcontext" state line expl suf ret=1
-  local args common common_transfer algopt tmp p1 file cmn cmds sdesc tdesc
+  local curcontext="$curcontext" state line expl suf arg ret=1
+  local args sigargs common common_transfer algopt tmp p1 file cmn cmds sdesc tdesc
   typeset -A opt_args
 
   common=(
@@ -126,53 +126,71 @@ _ssh () {
     (( CURRENT == 2 )) && p1='!'
     args=( '!-z:number' )
     sdesc='certify keys with CA key'
-    (( $+words[(r)-s] )) && args=( '-z[specify serial number]:serial number' )
+    (( $+words[(r)-I] )) && args=( '-z[specify serial number]:serial number' )
     (( $+words[(r)-[ku]] )) && args=( '-z[specify version number]:version number' ) &&
         sdesc='specify CA public key file'
     file=key
-    (( $+words[(r)-[HR]] )) && file=known_hosts
+    (( $+words[(r)-[FHR]] )) && file=known_hosts
     (( $+words[(r)-T] )) && file=input
-    if (( $+words[(r)-[kQ]] )); then
+    (( $+words[(r)-A] )) && file='prefix for host key'
+    if (( $+words[(r)-[kIQ]] )); then
       file=krl
       args+=( '*:file:_files' )
     fi
-    cmds=( -p -i -e -y -c -l -B -D -H -R -r -G -T -s -L -A -k -Q ) # basic commands
-    cmn=( -b -P -N -C -m -v ) # options common to many basic commands (except -f which is common to most)
-    cms=( -E -q -t -g -M -S -a -J -j -K -W -I -h -n -O -V -u ) # options specific to one basic command
+    if (( arg = $words[(I)-Y*] )); then
+      [[ $words[arg] = -Y?* ]] || (( arg++ ))
+      case $words[arg] in
+	check*|verify)
+	  sigargs+=( "$p1-s+[specify signature file]:signature file:-files" )
+	;|
+	sign) sigargs+=( '*:file:_files' ) ;;
+	verify)
+	  args=()
+	  sigargs+=(
+	    '-I+[specify signer identity]:identity'
+	    '-r+[specify revocation file]:revocation file:_files'
+	  )
+	;;
+      esac
+    fi
+    cmds=( -p -i -e -y -c -l -B -D -F -H -R -r -G -T -s -L -A -k -Q -Y ) # basic commands
+    cmn=( -b -P -N -C -l -m -v ) # options common to many basic commands (except -f which is common to most)
+    cms=( -E -q -t -g -M -S -a -J -j -K -W -I -h -n -O -V -u -U ) # options specific to one basic command
     _arguments -s $args \
-      "(${${(@)cmds:#-G}} -P -m ${${(@)cms:#-[MS]}})-b+[specify number of bits in key]:bits in key" \
-      "$p1(${${(@)cmds:#-[pc]}} -b -C $cms)-P+[provide old passphrase]:old passphrase" \
-      "(${${(@)cmds:#-p}} -m -v ${${(@)cms:#-[qt]}})-N+[provide new passphrase]:new passphrase" \
-      "(${${(@)cmds:#-c}} -m -v $cms)-C+[provide new comment]:new comment" \
+      "(${${(@)cmds:#-G}} -P ${${(@)cms:#-[MS]}})-b+[specify number of bits in key]:bits in key" \
+      "$p1(${${(@)cmds:#-[pc]}} -b $cms)-P+[provide old passphrase]:old passphrase" \
+      "(${${(@)cmds:#-p}} -v ${${(@)cms:#-[qt]}})-N+[provide new passphrase]:new passphrase" \
+      "(${${(@)cmds:#-c}} -v $cms)-C+[provide new comment]:new comment" \
       "(-D -G -M -S -I -h -n -O -V -A)-f+[$file file]:$file file:_files" \
-      "$p1(${${(@)cmds:#-[ie]}})-m+[specify conversion format]:format:(PEM PKCS7 RFC4716)" \
+      "$p1(${${(@)cmds:#-[FE]}} ${${(@)cmn:#-v}} ${${(@)cms:#-E}})-l[show fingerprint of key file]" \
+      "$p1(${${(@)cmds:#-[iep]}} $cms)-m+[specify conversion format]:format [RFC4716]:(PEM PKCS8 RFC4716)" \
       "(${${(@)cmds:#-[lGT]}} ${${(@)cmn:#-[bv]}} -f)*-v[verbose mode]" \
       - '(commands)' \
-      "(-b -P -C -v)-p[change passphrase of private key file]" \
-      '(-b -P -N -C -v)-i[import key to OpenSSH format]' \
-      '(-b -P -N -C -v)-e[export key to SECSH file format]' \
+      "(-b -l -C -v)-p[change passphrase of private key file]" \
+      '(-b -l -P -N -C -v)-i[import key to OpenSSH format]' \
+      '(-b -l -P -N -C -v)-e[export key to SECSH file format]' \
       "($cmn)-y[get public key from private key]" \
-      '(-b -N -m -v)-c[change comment in private and public key files]' \
+      '(-b -l -N -m -v)-c[change comment in private and public key files]' \
       "($cmn)-B[show the bubblebabble digest of key]" \
       "(-)-D+[download key stored in smartcard reader]:reader" \
+      "(${${(@)cmn:#-[lv]}})-F+[search for host in known_hosts file]:host:_ssh_hosts" \
       "($cmn)-H[hash names in known_hosts file]" \
       "($cmn)-R+[remove host from known_hosts file]:host:_ssh_hosts" \
       "($cmn)-L[print the contents of a certificate]" \
-      "(-)-A[generate host keys for all key types]" \
+      "($cmn -l)-A[generate host keys for all key types]" \
       "($cmn)-Q[test whether keys have been revoked in a KRL]" \
       - finger \
-      "($cmn)-l[show fingerprint of key file]" \
       "$p1($cmn)$algopt" \
       - create \
-      '(-P -m)-q[silence ssh-keygen]' \
-      "(-P -m)-t+[specify the type of the key to create]:key type:(rsa dsa ecdsa ed25519)" \
+      '(-P -l)-q[silence ssh-keygen]' \
+      "(-P -l)-t+[specify the type of the key to create]:key type:(rsa dsa ecdsa ed25519)" \
       - dns \
       "($cmn)-r[print DNS resource record]:hostname:_hosts" \
       "$p1($cmn)-g[use generic DNS format]" \
       - primes \
-      "(-P -N -C -m -f)-G[generate candidates for DH-GEX moduli]" \
-      "$p1(-P -N -C -m -f)-M+[specify amount of memory to use for generating DH-GEX moduli]:memory (MB)" \
-      "$p1(-P -N -C -m -f)-S+[specify start point]:start point (hex)" \
+      "(-P -N -C -l -m -f)-G+[generate candidates for DH-GEX moduli]:output file:_files" \
+      "$p1(-P -N -C -l -m -f)-M+[specify amount of memory to use for generating DH-GEX moduli]:memory (MB)" \
+      "$p1(-P -N -C -l -m -f)-S+[specify start point]:start point (hex)" \
       - screen \
       "(${${(@)cmn:#-v}})-T+[screen candidates for DH-GEX moduli]:output file:_files" \
       "${p1}(${${(@)cmn:#-v}})-a+[specify number of rounds]:rounds" \
@@ -182,19 +200,27 @@ _ssh () {
       "${p1}(${${(@)cmn:#-v}})-W[specify desired generator]:generator" \
       - certify \
       "($cmn)-s[$sdesc]:CA key:_files" \
-      "$p1($cmn -f -u)-I+[specify key identifier to include in certificate]:key id" \
-      "$p1($cmn -f -u)-h[generate host certificate instead of a user certificate]" \
-      "$p1($cmn -f -u -D)-U[indicate that CA key is held by ssh-agent]" \
-      "$p1($cmn -f -u -U)-D+[indicate the CA key is stored in a PKCS#11 token]:PKCS11 shared library:_files -g '*.(so|dylib)(|.<->)(-.)'" \
-      "$p1($cmn -f -u)-n+[specify user/host principal names to include in certificate]:principals" \
-      "$p1($cmn -f -u)*-O+[specify a certificate option]: : _values 'option'
+      "$p1($cmn -f -k -u)-I+[specify key identifier to include in certificate]:key id" \
+      "$p1($cmn -f -k -u)-h[generate host certificate instead of a user certificate]" \
+      "$p1($cmn -f -k -u -D)-U[indicate that CA key is held by ssh-agent]" \
+      "$p1($cmn -f -k -u -U)-D+[indicate the CA key is stored in a PKCS#11 token]:PKCS11 shared library:_files -g '*.(so|dylib)(|.<->)(-.)'" \
+      "$p1($cmn -f -k -u)-n+[specify user/host principal names to include in certificate]:principals" \
+      "$p1($cmn -f -k -u)*-O+[specify a certificate option]: : _values 'option'
         clear critical\:name extension\:name force-command\:command\:_cmdstring
 	no-agent-forwarding no-port-forwarding no-pty no-user-rc no-x11-forwarding
 	permit-agent-forwarding permit-port-forwarding permit-pty permit-user-rc
 	permit-x11-forwarding source-address\:source\ address" \
       "$p1($cmn -f -u)-V+[specify certificate validity interval]:interval" \
-      "($cmn -I -h -n -O -V)-k[generate a KRL file]" \
-      "$p1($cmn -I -h -n -O -V)-u[update a KRL]"
+      "($cmn -I -h -n -D -O -U -V)-k[generate a KRL file]" \
+      "$p1($cmn -I -h -n -D -O -U -V)-u[update a KRL]" \
+      - signature \
+      "($cmn)-Y+[signature action]:action:((
+	sign\:sign\ a\ file\ using\ SSH\ key
+	verify\:verify\ a\ signature\ generated\ using\ the\ sign\ option
+	check-novalidate\:check\ signature\ structure
+      ))" \
+      "$p1-n+[specify namespace]:namespace" \
+      $sigargs
     return
   ;;
   ssh-keyscan)
@@ -202,6 +228,7 @@ _ssh () {
       '(-6)-4[force ssh to use IPv4 addresses only]' \
       '(-4)-6[force ssh to use IPv6 addresses only]' \
       '-c[request certificates from target hosts instead of plain keys]' \
+      '-D[print keys found as SSHFP DNS records]' \
       '*-f+[read hosts from file, one per line]:file:_files' \
       '-H[hash all hostnames and addresses in the output]' \
       '-p+[specify port on remote host]:port number on remote host' \
@@ -529,6 +556,7 @@ _ssh () {
                 SendEnv \
                 ServerAliveCountMax \
                 ServerAliveInterval \
+                SetEnv \
                 StreamLocalBindMask \
                 StreamLocalBindUnlink \
                 StrictHostKeyChecking \



Messages sorted by: Reverse Date, Date, Thread, Author