From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18341 invoked by alias); 11 Dec 2015 07:53:03 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 37383 Received: (qmail 17390 invoked from network); 11 Dec 2015 07:53:01 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=V8fQl6O/H5Y9OlZiPRMxYc1xUXTg5Ev+uOc+mi6QFXs=; b=aXo3f3YSb1l0mDoFW7m6sACD32mXN2Wr2M3+ieH1oQoOSCLPNsRgETPOpHsQ5CM9bH oZj0QzXRXiFUGr9mcbDu1HzW8wGf9SpztVLoFakopuFqbF1iJqviYLCsa0pBwHFXsQsX u2TReOMjbtk5ebSQ76CvGjZ5pb4+rMZtkGS2Hw472FIXtOAqS44vIZDhkTJ5tt3/pZ5/ 9WbjQcZM8qAbL9vIC9wWAxATkWLTqU5lAwNkWgKukvVRWXrFv1IZOUpLEGA4fC5jQYXz iBRiJn7ds9H7+nu52YRpYOXv/olp/vuDc7rusCQGOUaoddZiplaIwGkLBcgN6577QPtB lb3w== X-Received: by 10.202.71.132 with SMTP id u126mr12819642oia.113.1449820375738; Thu, 10 Dec 2015 23:52:55 -0800 (PST) Date: Fri, 11 Dec 2015 01:52:54 -0600 From: Matthew Martin To: zsh-workers@zsh.org Subject: Re: [patch] Add _elf_files type Message-ID: <20151211075254.GA17305@CptOrmolo.darkstar> References: <20151211064440.GA19567@CptOrmolo.darkstar> <20260.1449818465@thecus.kiddle.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260.1449818465@thecus.kiddle.eu> User-Agent: Mutt/1.5.24 (2015-08-30) On Fri, Dec 11, 2015 at 08:21:05AM +0100, Oliver Kiddle wrote: > Matthew Martin wrote: > > 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. > > This seems sensible. > > Don't some systems including even Mac OS X use something other than ELF? > With that in mind, should it perhaps be named _object_files? I considered that, but picked elf for no real reason. _object_files is fine with me. > Also, can we perhaps be a little more generous on matching core files? > > On Linux it is configurable via /proc/sys/kernel/core_pattern, similarly > on Solaris via coreadm(1M) and FreeBSD via the sysctl variable > kern.corefile. > > While the defaults for those systems are core.pid, core and cmd.core, > respectively, I'd be inclined to match (core*|*.core) on any system. Works for me. diff --git a/Completion/Unix/Command/_elfdump b/Completion/Unix/Command/_elfdump index ee92402..065f4b9 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:_object_files" ) ;; freebsd*) args+=( '-a[dump all information]' ) ;; diff --git a/Completion/Unix/Command/_nm b/Completion/Unix/Command/_nm index d171ef5..73d7508 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:_object_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..cc213d9 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:_object_files' diff --git a/Completion/Unix/Command/_readelf b/Completion/Unix/Command/_readelf index 9312ea8..a474a8d 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:_object_files" ) case $variant in diff --git a/Completion/Unix/Type/_object_files b/Completion/Unix/Type/_object_files new file mode 100644 index 0000000..31a13ae --- /dev/null +++ b/Completion/Unix/Type/_object_files @@ -0,0 +1,11 @@ +#autoload + +local expl + +_description files expl 'object file' + +__object_file() { + [[ -x $REPLY || $REPLY = *.([ao]|so|elf)(.<->)## || $REPLY = (core*|*.core) ]] +} + +_files -g '*(-.e,__object_file,)'