Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[patch] Add _cksum
- X-seq: zsh-workers 42643
- From: Matthew Martin <phy1729@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [patch] Add _cksum
- Date: Fri, 13 Apr 2018 22:37:51 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mail-followup-to:mime-version :content-disposition:user-agent; bh=7J0mKgqCwgdi/EjDF1CrSuzqT+FOAryEJPMLOK8dROI=; b=iJHl0c2TvsyzwueM8TihzES/EABcBnmXnbNKxfeIodhkqXOMSvKhW7eUPRaW1d6Oof kCg1I5MHT3gi0/utD7eC4i04KsKU9ycj9Gg2gtAkLaCOXV1QeK6KjqB7teQhnm2Wde3Z zQTGW7jvnZvZnGVzWUNYKyaKM3S+a3mDQwPe3gH5hejgtbomgZKU5RIoIYOqJ0JzKHkB TfIJiOZ1M1wLagyje44Fv1d41NRkWfuJ6PaGRJdU+h0n07qSHjkfSE3s8OwJMpTNJ6/B H/hQUkbRnWJjhhEvU//0+ng50G3We0bdvtu1WwPRvSd/oNkmIY8gx2SaahV4fBT7Okxt G1mA==
- 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>
- Mail-followup-to: zsh-workers@xxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
Add completion for cksum (sum, md[245], rmd160, sha*).
Is there a way to not repeat algoithm in
'*-a+[use the specfied algorithm(s)]:algorithm:_values -s , algotithm cksum md5 rmd160 sha1 sha224 sha256 sha384 sha512/256 sha512'
- Matthew Martin
diff --git a/Completion/BSD/Command/_cksum b/Completion/BSD/Command/_cksum
new file mode 100644
index 000000000..24edc7252
--- /dev/null
+++ b/Completion/BSD/Command/_cksum
@@ -0,0 +1,67 @@
+#compdef cksum sum=cksum md2 md4 md5 rmd160 sha1 sha256 sha512
+
+if [[ $OSTYPE == (dragonfly|freebsd)* && service == cksum ]]; then
+ _arguments -s -S -A '-*' \
+ '-o[use specified historic algorithm]:historic algorithm:(1 2 3)' \
+ '*:_files'
+
+else
+ local -a args
+
+ case $OSTYPE in
+ dragonfly*|freebsd*|netbsd*)
+ args+=(
+ '-t[run built-in time trial]'
+ )
+ ;|
+ dragonfly*|freebsd*|openbsd*)
+ args+=(
+ '-r[reverse the output format]'
+ )
+ ;|
+ dragonfly*)
+ args+=(
+ '-b+[begin at specified offset]:begin offset: '
+ '-e+[end at specified offset]:end offset: '
+ )
+ ;;
+ freebsd*)
+ args+=(
+ '-c+[compare digest against specified string]:digest string: '
+ )
+ ;;
+ netbsd*)
+ args+=(
+ '(*)-c+[compare checksums against specifed sumfile]:sumfile:_files'
+ '-n[reverse the output format]'
+ '-w[warn on malformed checksum files]'
+ )
+ if [[ $service == cksum ]]; then
+ args=(
+ '(-o)-a+[use the specfied algorithm(s)]:algorithm:(crc md2 md4 md5 old1 old2 rmd160 sha1 sha256 sha384 sha512)'
+ '(-a)-o+[use the specfied historic algorithm]:historic algorithm:(1 2)'
+ )
+ fi
+ ;;
+ openbsd*)
+ args+=(
+ '-b[output in base 64]'
+ '-C+[compare checksums against specifed checklist]:checklist:_files'
+ '-c[file arguments are checklists]'
+ '-h+[output to specified hashfile]:hashfile:_files'
+ '*-t[run built-in time trial]'
+ )
+ if [[ $service == cksum ]]; then
+ args+=('*-a+[use the specfied algorithm(s)]:algorithm:_values -s , algotithm cksum md5 rmd160 sha1 sha224 sha256 sha384 sha512/256 sha512')
+ fi
+ ;;
+ esac
+
+ _arguments -s -S -A '-*' \
+ $args \
+ '-p[echo stdin to stdout]' \
+ '-q[quiet mode]' \
+ '-s+[checksum specified string]:string: ' \
+ '-x[run built-in test]' \
+ '*:_files'
+fi
Messages sorted by:
Reverse Date,
Date,
Thread,
Author