From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Zsh workers <zsh-workers@zsh.org>
Subject: PATCH: completion for strings
Date: Thu, 29 Mar 2018 10:09:44 +0200 [thread overview]
Message-ID: <13770.1522310984@thecus> (raw)
Our completion coverage for standard Unix utilities is by now fairly
comprehensive. strings - which in GNU terms is binutils rather than
coreutils - was missing so this adds it.
Oliver
diff --git a/Completion/Unix/Command/_strings b/Completion/Unix/Command/_strings
new file mode 100644
index 000000000..8eeff704b
--- /dev/null
+++ b/Completion/Unix/Command/_strings
@@ -0,0 +1,73 @@
+#compdef strings gstrings eu-strings
+
+local args variant format bytes
+format='[precede each string by its byte offset in the file]:format:((d\:decimal o\:octal x\:hexadecimal))'
+bytes='[specify minimum string length]:length (bytes) [4]'
+args=(
+ '(-t --radix)-o[precede each string by its decimal byte offset]'
+ '!(-n --bytes)-'{1,2,3,4,5,6,7,8,9}
+)
+
+if _pick_variant -r variant binutils=GNU elftoolchain=elftoolchain elfutils=elfutils unix -V; then
+ args+=(
+ '(-a --all -d --data)'{-a,--all}'[look everywhere in file, not just initialised data space of object files]'
+ '(-e --encoding)'{-e+,--encoding=}'[select character size and endianness]:character type:((
+ s\:7-bit
+ S\:8-bit
+ b\:16-bit\ big-endian
+ l\:16-bit\ little-endian
+ B\:32-bit\ big-endian
+ L\:32-bit\ little-endian))'
+ '(-f --print-file-name)'{-f,--print-file-name}'[print name of the file before each string]'
+ '(-n --bytes)'{-n+,--bytes=}"$bytes"
+ '(-d -t --radix)'{-t+,--radix=}"$format"
+ '(- *)--help[display help information]'
+ '(- *)--version[display version information]'
+ )
+ case $variant in
+ elfutils|binutils)
+ args+=( '(- *)-V[display version information]' )
+ ;|
+ elftoolchain|binutils)
+ args+=(
+ '(- *)-h[display help information]'
+ '(- *)-v[display version information]'
+ )
+ ;|
+ binutils)
+ args+=(
+ '(-a --all -d --data)'{-d,--data}'[only print strings from file data sections]'
+ '(-w --include-all-whitespace)'{-w,--include-all-whitespace}'[include all whitespace as valid string characters]'
+ '(-T --target)'{-T+,--target=}'[specify binary file format]:format:compadd - ${(z)${(M)${(f)"$(_call_program targets strings --help)"}##* supported targets*}##*\: }'
+ '(-s --output-separator)'{-s+,--output-separator=}'[specify string used to separate strings in output]'
+ )
+ ;;
+ elfutils)
+ args+=(
+ '(- *)--usage[display a short usage message]'
+ '(- *)-\\?[display help information]'
+ )
+ ;;
+ esac
+else
+ args+=(
+ "(-d)-t+$format"
+ "-n+$bytes"
+ '-a[look everywhere in file, not just initialised data space of object files]'
+ )
+ case $OSTYPE in
+ darwin)
+ local -a arch
+ arch=( ${${${"$(_call_program architectures strings -arch \? 2>&1)"}#*flags are: }%%$'\n'*} )
+ args+=( '-arch[specify the architecture]:architecture:compadd -a arch' )
+ ;;
+ esac
+fi
+
+if compset -P '@'; then
+ _files
+ return
+fi
+
+_arguments -S -s $args \
+ '*:file:_files'
next reply other threads:[~2018-03-29 18:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-29 8:09 Oliver Kiddle [this message]
2018-04-03 8:49 ` Jun T
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=13770.1522310984@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).