From: Matthew Martin <phy1729@gmail.com>
To: zsh-workers@zsh.org
Subject: [patch] Add _elf_files type
Date: Fri, 11 Dec 2015 00:44:41 -0600 [thread overview]
Message-ID: <20151211064440.GA19567@CptOrmolo.darkstar> (raw)
elfdump, nm, objdump, and readelf all had a similar way of determining
what files they would complete. Move this into _elf_files. Also adds
patterns for core files and versioned libraries.
- Matthew Martin
diff --git a/Completion/Unix/Command/_elfdump b/Completion/Unix/Command/_elfdump
index ee92402..4670d75 100644
--- a/Completion/Unix/Command/_elfdump
+++ b/Completion/Unix/Command/_elfdump
@@ -2,10 +2,6 @@
local -a args
-_elf_file() {
- [[ -x $REPLY || $REPLY = (core*|*.([ao]|so|elf)) ]]
-}
-
args=(
'-c[dump section header information]'
'-d[dump .dynamic section]'
@@ -38,7 +34,7 @@ case $OSTYPE in
'-l[show long section names without truncation]'
'-O[specify osabi to apply]:osabi'
'-P[use alternative section header]'
- "*:elf file:_files -g '*(-.e:_elf_file:)'"
+ "*:elf file:_elf_files"
)
;;
freebsd*) args+=( '-a[dump all information]' ) ;;
diff --git a/Completion/Unix/Command/_nm b/Completion/Unix/Command/_nm
index d171ef5..df5f1eb 100644
--- a/Completion/Unix/Command/_nm
+++ b/Completion/Unix/Command/_nm
@@ -2,11 +2,7 @@
local args files variant
-_nm_object_file() {
- [[ -x $REPLY || $REPLY = *.([ao]|so|elf) ]]
-}
-
-files="*:object file:_files -g '*(-.e,_nm_object_file,)'"
+files="*:object file:_elf_files"
args=(
'(-A -o --print-file-name)'{-A,-o,--print-file-name}'[print name of input file on each line]'
'(--demangle)-C[decode symbol names]'
diff --git a/Completion/Unix/Command/_objdump b/Completion/Unix/Command/_objdump
index 607719a..b092df4 100644
--- a/Completion/Unix/Command/_objdump
+++ b/Completion/Unix/Command/_objdump
@@ -1,8 +1,3 @@
#compdef objdump
-# borrowed from _nm_object_file
-_objdump_object_file() {
- [[ -x $REPLY || $REPLY = *.([ao]|so|elf) ]]
-}
-
-_arguments -- '*:object file:_files -g "*(-.e,_objdump_object_file,)"'
+_arguments -- '*:object file:_elf_files'
diff --git a/Completion/Unix/Command/_readelf b/Completion/Unix/Command/_readelf
index 9312ea8..b3a24c8 100644
--- a/Completion/Unix/Command/_readelf
+++ b/Completion/Unix/Command/_readelf
@@ -2,10 +2,6 @@
local variant args sections
-_elf_file() {
- [[ -x $REPLY || $REPLY = (core*|*.([ao]|so|elf)) ]]
-}
-
sections=( .bss .data .dynamic .dynsym .got .interp .shstrtab .symtab .text )
_pick_variant -r variant elftoolchain=elftoolchain elfutils=elfutils binutils --version
@@ -29,7 +25,7 @@ args=(
'(-W --wide)'{-W,--wide}'[allow output width to exceed 80 characters]'
'(- *)'{-H,--help}'[display help information]'
'(- *)'{-v,--version}'[display version information]'
- "*:elf file:_files -g '*(-.e:_elf_file:)'"
+ "*:elf file:_elf_files"
)
case $variant in
diff --git a/Completion/Unix/Type/_elf_files b/Completion/Unix/Type/_elf_files
new file mode 100644
index 0000000..68b2fbc
--- /dev/null
+++ b/Completion/Unix/Type/_elf_files
@@ -0,0 +1,13 @@
+#autoload
+
+local expl
+
+_description files expl 'elf object file'
+
+__object_file() {
+ [[ -x $REPLY || $REPLY = *.([ao]|so|elf)(.<->)## ]] ||
+ [[ $OSTYPE = linux* && $REPLY = core.* ]] ||
+ [[ $OSTYPE = openbsd* && $REPLY = *.core ]]
+}
+
+_files -g '*(-.e,__object_file,)'
next reply other threads:[~2015-12-11 6:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-11 6:44 Matthew Martin [this message]
2015-12-11 7:21 ` Oliver Kiddle
2015-12-11 7:52 ` Matthew Martin
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=20151211064440.GA19567@CptOrmolo.darkstar \
--to=phy1729@gmail.com \
--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).