From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6230 invoked from network); 11 Mar 2005 10:47:58 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 11 Mar 2005 10:47:58 -0000 Received: (qmail 94803 invoked from network); 11 Mar 2005 10:47:52 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 11 Mar 2005 10:47:52 -0000 Received: (qmail 14346 invoked by alias); 11 Mar 2005 10:47:49 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 20968 Received: (qmail 14333 invoked from network); 11 Mar 2005 10:47:48 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 11 Mar 2005 10:47:48 -0000 Received: (qmail 94528 invoked from network); 11 Mar 2005 10:47:46 -0000 Received: from lorien.emufarm.org (HELO lorien.comfychair.org) (64.81.48.166) by a.mx.sunsite.dk with SMTP; 11 Mar 2005 10:47:42 -0000 Received: from lorien.comfychair.org (localhost [127.0.0.1]) by lorien.comfychair.org (8.13.1/8.12.11) with ESMTP id j2BAlbC8004616; Fri, 11 Mar 2005 02:47:37 -0800 Received: (from duvall@localhost) by lorien.comfychair.org (8.13.1/8.12.11/Submit) id j2BAlb9b004615; Fri, 11 Mar 2005 02:47:37 -0800 Date: Fri, 11 Mar 2005 02:47:37 -0800 From: Danek Duvall To: Andrey Borzenkov Cc: zsh-workers@sunsite.dk Subject: Re: [PATCH] _fuser Solaris and SVR4 support Message-ID: <20050311104737.GA30225@lorien.comfychair.org> Mail-Followup-To: Danek Duvall , Andrey Borzenkov , zsh-workers@sunsite.dk References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.6i X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 On Thu, Mar 10, 2005 at 06:04:16PM +0300, Andrey Borzenkov wrote: > I have access to Solaris 9 only so please extend this with > other versions (BTW Solaris 10 is now 5.10 not 2.10). Hm? How's that work? The zsh that ships with Solaris 10 says solaris2.10 for $OSTYPE .... Another thing to note is that the value of $OSTYPE is compiled in, so relying on it may be the wrong thing if zsh is mounted from a shared directory. Features also may be backported to older releases, so even the output of uname -r isn't necessarily going to be right. Here's a proposed patch that parses the output of "fuser -?". It works correctly for Solaris 8, 9, and 10, AFAICT. Coming up with this was just too difficult, and someone surely can figure out a better way of doing it. Index: Completion/Unix/Command/_fuser =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_fuser,v retrieving revision 1.2 diff -u -r1.2 _fuser --- Completion/Unix/Command/_fuser 10 Mar 2005 18:38:16 -0000 1.2 +++ Completion/Unix/Command/_fuser 11 Mar 2005 10:46:05 -0000 @@ -1,6 +1,6 @@ #compdef fuser -local -a args arg1 +local -a args if _pick_variant -c $words[1] gnu=GNU unix -V; then _arguments \ @@ -20,23 +20,54 @@ ':name:_files' else case $OSTYPE in - solaris2.9 ) - args=( - '-n[list only processes with non-blocking mandatory locks]' - '-s[send alternate signal with -k]:signal:_signals' + solaris* ) + local usage b z + local -a block arg oarg + local -A desc + + usage=${(M)${(f)"$(fuser -\? 2>&1)"}:#Usage*} + block=( ${(s:+:)${${${${${${usage[(w)3,(r)files]}[1,(w)-2]}#\[-}%]}//s sig/s}//[\[\]]##/+}} ) + desc=( + c "list all processes accessing files on the filesystem specified by name" + d "list all processes accessing minor nodes bound to the same device node" + f "list all processes accessing named files" + k "kill matched processes with SIGKILL" + n "list only processes with non-blocking mandatory locks" + s "send signal to matched processes" + u "append the user name of the process owner to each PID" ) + + for b in $block; do + if [[ $b == *\|* ]]; then + for z in ${(s:|:)b}; do + if [[ $z == "s" ]]; then + oarg=( -${^${(s:|:)b}:#$z} ) + arg=( \($^^oarg\)-$z\[$desc[$z]]:signal:_signals ) + args=( $args "$arg" ) + else + oarg=( -${^${(s:|:)b}:#$z} ) + arg=( \($^^oarg\)-$z\[$desc[$z]] ) + args=( $args "$arg" ) + fi + done + else + for z in ${(s::)b}; do + args=( $args "-${z}[$desc[$z]]") + done + fi + done + + _arguments $args ':name:_files' ;; sysv4 ) - arg1=( ':signal:_signals -p' ) + _arguments \ + '(-f)-c[list all processes accessing files on the filesystem specified by name]' \ + '(-c)-f[list all processes accessing named files]' \ + '-k[kill processes accessing the file]' \ + '-u[append the user name of the process owner to each PID]' \ + ':signal:_signals -p' \ + ':name:_files' ;; esac - _arguments \ - '(-f)-c[list all processes accessing files on the filesystem specified by name]' \ - '(-c)-f[list all processes accessing named files]' \ - '-k[kill processes accessing the file]' \ - '-u[append the user name of the process owner to each PID]' \ - $args \ - $arg1 \ - ':name:_files' fi Danek