[Pm-utils] [patch] fix modunload function
Stefan Seyfried
seife at suse.de
Fri Mar 16 06:06:09 PDT 2007
Hi,
modunload currently does not unload anything but "pcmcia" for me.
I'm not sure why this is happening, maybe it is even a bug in my
bash, since
root at strolchi:/# A=button
root at strolchi:/# B=$A
root at strolchi:/# [[ "$A" =~ "$B" ]] || echo hello
hello
looks strange. However, i also think my code is simpler and cleaner:
Index: pm/functions
===================================================================
RCS file: /cvs/pm-utils/pm-utils/pm/functions,v
retrieving revision 1.41
diff -u -p -r1.41 functions
--- pm/functions 15 Mar 2007 00:42:56 -0000 1.41
+++ pm/functions 16 Mar 2007 13:01:42 -0000
@@ -191,13 +191,14 @@ modunload()
{
local MOD D C USED MODS I
local UNL=$1 RET=1
- UNL=$(echo $UNL | sed -e 's/[_-]/\[_-\]/g')
+ # the kernel only knows underscores in module names, no dashes
+ UNL=${UNL//-/_}
# RET is the return code.
# If at least one module was unloaded, return 0.
# if the module was not loaded, also return 0 since this is no error.
# if no module was unloaded successfully, return 1
while read MOD D C USED D; do
- [[ "$MOD" =~ "$UNL" ]] || continue
+ [ "$MOD" = "$UNL" ] || continue
if [ "$USED" == "-" ]; then
_rmmod $MOD $C
RET=$?
--
Stefan Seyfried
"Any ideas, John?"
"Well, surrounding them's out."
More information about the Pm-utils
mailing list