[Pm-utils] function source_configs?
Peter Jones
pjones at redhat.com
Sat Oct 21 13:15:52 PDT 2006
On Fri, 2006-10-06 at 14:52 +0200, Stefan Seyfried wrote:
> + for cfg in $(ls -1 /etc/pm/config.d/*[^~] 2>/dev/null) ; do
> + while read LINE; do
> + SKIP=false
> + for v in $GLOBAL_CONFIG_VARIABLES ; do
> + case "$LINE" in
> + $v=*) SKIP=true ;;
> + esac
> + done
> + $SKIP && continue
> + eval $LINE
> + done < $cfg
Still seems a little wordy, and the third loop kindof bugs me. How
about:
source_configs()
{
- for cfg in $(ls -1 /etc/pm/config.d/* 2>/dev/null) ; do
- [[ "$cfg" =~ ".*~$" ]] && continue
- STR=". $cfg"
- for v in $GLOBAL_CONFIG_VARIABLES ; do
- STR="$STR ; echo x_$v=\"\$(eval echo \$$v)\""
- done
- eval $(bash -c "$STR")
- for v in $GLOBAL_CONFIG_VARIABLES ; do
- eval $v="$(eval echo $(eval echo \$$v) \$x_$v)"
- done
+ cfgs="/etc/pm/config.d/*[^~]"
+ for cfg in $cfgs ; do
+ [ -x $cfg ] || continue
+ while read LINE ; do
+ case "$GLOBAL_CONFIG_VARIABLES " in
+ *" ${LINE%=*} "*) continue ;;
+ *) eval $LINE ;;
+ esac
+ done < $cfg
done
}
--
Peter
More information about the Pm-utils
mailing list