summaryrefslogtreecommitdiff
path: root/pm
diff options
context:
space:
mode:
authorVictor Lowther <victor.lowther@gmail.com>2008-03-18 19:05:31 -0500
committerVictor Lowther <victor.lowther@gmail.com>2008-03-18 19:05:31 -0500
commite49b18c42f3c501e3d352df8b5356ba8cff1e6ab (patch)
tree1b3ecbc326a6044be48a77beda503e5f0a44c422 /pm
parent2d224fc56941d6c6c65b51d0e9943b331b8e69b8 (diff)
Updated /etc/pm/parameters parsing.
Now we can add and remove parameters passed from our invoker.
Diffstat (limited to 'pm')
-rw-r--r--pm/pm-functions.in26
1 files changed, 22 insertions, 4 deletions
diff --git a/pm/pm-functions.in b/pm/pm-functions.in
index 2c97848..f4686ee 100644
--- a/pm/pm-functions.in
+++ b/pm/pm-functions.in
@@ -64,18 +64,36 @@ load_hook_blacklist()
done
}
+remove_parameter() {
+ local x=""
+ for p in $PM_CMDLINE; do
+ [ "$1" = "$p" ] && continue
+ x="$x $p"
+ shift # not a bug!
+ done
+ PM_CMDLINE="$x"
+}
+
+add_parameter() {
+ PM_CMDLINE="$PM_CMDLINE $@"
+}
+
load_hook_parameters()
{
[ -f "$PM_UTILS_ETCDIR/parameters" ] || return
- # loop through the parameters file, and add each line in it to the
- # end of PM_CMDLINE.
+ # loop through the parameters file, and perform the appropriate
+ # action for each parameter.
+ # Currently, only "add" and "drop" are supported.
# Comments begin with hashmarks and run to the end of the line.
# Because we are modifying an env var, the while read loop cannot
# run in a pipe like the previous one did.
- while read parameter; do
+ while read action parameter; do
parameter="$(echo $parameter |sed 's,#.*$,,g')"
[ -z "$parameter" ] && continue
- PM_CMDLINE="${PM_CMDLINE} $parameter"
+ case $action in
+ add) add_parameter $parameter ;;
+ drop) remove_parameter $parameter ;;
+ esac
done < "$PM_UTILS_ETCDIR/parameters"
}