From: Oliver Kiddle <opk@u.genie.co.uk>
To: zsh-workers@sunsite.dk
Subject: Re: PATCH: rmmod/modprobe -r completion
Date: Tue, 15 May 2001 16:07:14 +0100 [thread overview]
Message-ID: <3B014622.7EE4888@u.genie.co.uk> (raw)
In-Reply-To: <20010514222601.A18298@dman.com>
Clint Adams wrote:
>
> This lacks all the other options to modprobe, and ignores
> insmod, but it seemed silly to just do rmmod and not have it work
> for modprobe -r.
This will be useful, cheers.
> Index: Completion/Unix/Command/_modutils
This is probably the first thing which really could be in a Linux
directory. It's probably best to move it later once we have others
though.
> +if [[ -f /proc/modules ]]; then
> + loaded=(${${(f)"$(</proc/modules)"}%% *})
> +elif [[ -x /sbin/lsmod ]]; then
> + loaded=(${${${(f)"$(</sbin/lsmod)"}%% *}%Module})
^
oops: you don't want to redirect in the /sbin/lsmod binary you want to
run it. I made a very similar mistake once when I tried to run a shell
script to fill out parameters to rm -rf - the result was not good.
> +compadd -a loaded
> +return 0
I also changed this to use _wanted so we get a description. I removed
the return statement because it should return 1 if the loaded array is
created but empty.
> + '*:loaded module:_modutils_loaded_modules'
Hmm, this is fine but I'd have used a state or cached the loaded array
and passed it to _arguments. Which is more efficient - functions
declared in the autoloaded functions or states?
Oliver
Index: Completion/Unix/Command/_modutils
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_modutils,v
retrieving revision 1.1
diff -u -r1.1 _modutils
--- Completion/Unix/Command/_modutils 2001/05/15 02:32:53 1.1
+++ Completion/Unix/Command/_modutils 2001/05/15 15:01:39
@@ -1,19 +1,18 @@
#compdef modprobe rmmod
-local loaded
+local expl loaded
_modutils_loaded_modules() {
-if [[ -f /proc/modules ]]; then
+if [[ -r /proc/modules ]]; then
loaded=(${${(f)"$(</proc/modules)"}%% *})
elif [[ -x /sbin/lsmod ]]; then
- loaded=(${${${(f)"$(</sbin/lsmod)"}%% *}%Module})
+ loaded=(${${(f)"$(/sbin/lsmod)"}[2,-1]%% *})
else
return 1
fi
-compadd -a loaded
-return 0
+_wanted modules expl 'loaded module' compadd -a loaded
}
case "$service" in
next prev parent reply other threads:[~2001-05-15 15:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-05-15 2:26 Clint Adams
2001-05-15 15:07 ` Oliver Kiddle [this message]
2001-05-16 12:00 ` Clint Adams
2001-05-16 12:32 ` Clint Adams
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=3B014622.7EE4888@u.genie.co.uk \
--to=opk@u.genie.co.uk \
--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).