From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Zsh workers <zsh-workers@zsh.org>
Subject: PATCH: handle system specific arguments in _dd
Date: Wed, 18 Apr 2018 00:08:57 +0200 [thread overview]
Message-ID: <13743.1524002937@thecus> (raw)
This expands dd completion to deal with system specifics.
Oliver
diff --git a/Completion/Unix/Command/_dd b/Completion/Unix/Command/_dd
index e51337f21..e5c5e63ce 100644
--- a/Completion/Unix/Command/_dd
+++ b/Completion/Unix/Command/_dd
@@ -1,17 +1,99 @@
#compdef dd gdd
-_values -w 'option' \
- 'if[specify input file]:input file:_tilde_files' \
- 'of[specify output file]:output file:_tilde_files' \
- '(bs)ibs[input block size]:block size (bytes)' \
- '(bs)obs[output block size]:block size (bytes)' \
- '(ibs obs)bs[block size]:block size (bytes)' \
- 'cbs[conversion buffer size]:buffer size (bytes)' \
- 'skip[input blocks initially skipped]:blocks' \
- 'seek[output blocks initially skipped]:blocks' \
- 'files[specify number of input files to copy and concatenate]:number of files' \
- 'count[number of input blocks to copy]:blocks' \
- 'conv[specify conversions to apply]:conversion:_values -s , conversion
- "(ebcdic ibm)ascii" "(ascii ibm)ebcdic" "(ascii ebcdic)ibm"
- "(unblock)block" "(block)unblock"
- "(ucase)lcase" "(lcase)ucase" swab noerror sync'
+local -a vals conv flags
+local variant
+
+_pick_variant -r variant gnu=GNU $OSTYPE --version
+
+vals=(
+ '(ibs obs)bs[block size]:block size (bytes)'
+ 'cbs[conversion buffer size]:buffer size (bytes)'
+ 'conv[specify conversions to apply]: :_values -s , conversion $conv'
+ 'count[number of input blocks to copy]:blocks'
+ '(bs)ibs[input block size]:block size (bytes)'
+ 'if[specify input file]:input file:_tilde_files'
+ '(bs)obs[output block size]:block size (bytes)'
+ 'of[specify output file]:output file:_tilde_files'
+ 'seek[output blocks initially skipped]:blocks'
+ 'skip[input blocks initially skipped]:blocks'
+)
+conv=(
+ '(ascii asciib oldascii ebcdic ebcdicb oldebcdic ibm ibmb oldibm)'{ascii,ebcdic,ibm}
+ '(unblock)block' '(block)unblock'
+ '(ucase)lcase' '(lcase)ucase'
+ swab sync noerror notrunc
+)
+
+case $variant in
+ ^gnu)
+ vals+=(
+ 'files[specify number of input files to copy and concatenate]:number of files'
+ )
+ ;|
+ (gnu|darwin|dragonfly|(free|net)bsd*)
+ conv+=( sparse )
+ ;|
+ gnu|netbsd*)
+ vals+=(
+ '*iflag[specify read flags]:flag:_sequence compadd - $flags'
+ '*oflag[specify write flags]:flag:_sequence compadd - $flags'
+ )
+ flags=( append direct directory dsync sync nonblock noctty nofollow )
+ ;|
+ darwin*|dragonfly*|(free|net)bsd*)
+ vals+=(
+ 'oseek[output blocks initially skipped]:blocks'
+ )
+ conv+=(
+ '(ascii oldascii ebcdic oldebcdic oldibm)'old{ascii,ebcdic,ibm}
+ )
+ ;|
+ (darwin|dragonfly|freebsd|netbsd|solaris)*)
+ vals+=(
+ 'iseek[input blocks initially skipped]:blocks'
+ )
+ ;|
+ (open|free)bsd*)
+ vals+=(
+ 'status[specify level of information to print to stderr]:level:(none noxfer)'
+ )
+ conv+=( osync )
+ ;|
+
+ freebsd*)
+ vals+=(
+ 'fillchar[specify padding character]:character'
+ 'speed[limit copying speed]:speed (bytes/second)'
+ )
+ conv+=(
+ '(pareven parnone parodd parset)'{pareven,parnone,parodd,parset}
+ )
+ ;;
+ gnu)
+ vals+=(
+ 'status[specify level of information to print to stderr]:level:(none noxfer progress)'
+ )
+ flags+=( fullblock noatime nocache count_bytes skip_bytes seek_bytes )
+ conv+=( excl nocreat fdatasync fsync )
+ ;;
+ netbsd*)
+ vals+=(
+ 'msgfmt[specify format for information summary]:format:(quiet posix human)'
+ 'progress[enable progress display]:enable:(1)'
+ )
+ flags+=(
+ wronly rdwr creat trunc excl shlock exlock cloexec nosigpipe rsync alt_io async
+ )
+ ;;
+ solaris*)
+ vals+=(
+ 'files[specify number of input files to copy and concatenate]:number of files'
+ 'oseek[output blocks initially skipped (via seek, not NUL-padding)]:blocks'
+ )
+ conv+=(
+ '(ascii asciib ebcdic ebcdicb ibmb)'{ascii,ebcdic,ibm}b
+ )
+ ;;
+esac
+
+_values -w 'option' $vals
reply other threads:[~2018-04-17 22:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=13743.1524002937@thecus \
--to=okiddle@yahoo.co.uk \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).