diff options
Diffstat (limited to 'pm')
-rw-r--r-- | pm/pm-functions.in | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/pm/pm-functions.in b/pm/pm-functions.in index 5068781..f4bf755 100644 --- a/pm/pm-functions.in +++ b/pm/pm-functions.in @@ -71,19 +71,40 @@ load_hook_blacklist() done } +remove_parameter() { + local x="" + for p in $PM_CMDLINE; do + [ "$1" = "$p" ] && { + log "Removing parameter $1." + continue + } + x="$x $p" + [ "$2" ] && shift + done + PM_CMDLINE="$x" +} + +add_parameter() { + log "Adding parameters $@" + 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 - log "Adding $parameter to PM_CMDLINE." - PM_CMDLINE="${PM_CMDLINE} $parameter" + case $action in + add) add_parameter $parameter ;; + drop) remove_parameter $parameter ;; + esac done < "$PM_UTILS_ETCDIR/parameters" } |