Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: completion for strings
- X-seq: zsh-workers 42566
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: completion for strings
- Date: Thu, 29 Mar 2018 10:09:44 +0200
- Authentication-results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.co.uk
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1522348845; bh=rS64yZWtHuEaVk7shCpls0b9YcS1r/2AM1506t671PQ=; h=From:To:Subject:Date:From:Subject; b=ow98L/Tsilsu6sGvAjSl4HQwnHZJtmez8ogN/KeVPU1sJR0sQwkGNUXKP/dzx2tG8f57IqV1bV6Vg78t9Q6VUQ4l0q/8+c7WruqLZk80GipkoQ0C7c1YYd3NTE78fRnku6EMkFLUr/dsLxpLKk4giutvVQM+mqs1i9IohKARCTbhQwhBbLECsjTquFjPxQogMcDjx5RVWPwHsYaDp84Z4ZCLSsfPsLL1iM7+oi7LtFt1aCH3ZyITHF/gbSKu6wBPRHKQ4UpEtIOFAHSnQwx6GwazZe7yKQf/k0sKBiNNXm0H27tjtVdBOM535w78Kj+KCdfDhowtx470LyoibtJXBg==
- 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
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'
Messages sorted by:
Reverse Date,
Date,
Thread,
Author