From: Danek Duvall <duvall@comfychair.org>
To: Andrey Borzenkov <arvidjaar@mail.ru>
Cc: zsh-workers@sunsite.dk
Subject: Re: [PATCH] _fuser Solaris and SVR4 support
Date: Fri, 11 Mar 2005 02:47:37 -0800 [thread overview]
Message-ID: <20050311104737.GA30225@lorien.comfychair.org> (raw)
In-Reply-To: <E1D9PCy-000Gis-00.arvidjaar-mail-ru@f9.mail.ru>
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
next prev parent reply other threads:[~2005-03-11 10:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-10 15:04 Andrey Borzenkov
2005-03-11 9:37 ` Oliver Kiddle
2005-03-12 7:46 ` Andrey Borzenkov
2005-03-21 17:08 ` Oliver Kiddle
2005-03-22 18:46 ` Andrey Borzenkov
2005-03-22 19:28 ` Oliver Kiddle
2005-03-11 10:47 ` Danek Duvall [this message]
2005-03-11 11:15 ` Oliver Kiddle
2005-03-12 7:53 ` Andrey Borzenkov
2005-03-12 7:55 ` Andrey Borzenkov
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=20050311104737.GA30225@lorien.comfychair.org \
--to=duvall@comfychair.org \
--cc=arvidjaar@mail.ru \
--cc=zsh-workers@sunsite.dk \
/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).