[Pm-utils] function source_configs?

Stefan Seyfried seife at suse.de
Mon Oct 30 01:15:40 PST 2006


Hi,

back from vacation, so let's start again :-)

On Sat, Oct 21, 2006 at 04:15:52PM -0400, Peter Jones wrote:
> 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

until now, config files did not need the eXecutable bit set, so this needs to
be documented (or [ -r $cfg ] ||...).

> +               while read LINE ; do
> +                       case "$GLOBAL_CONFIG_VARIABLES " in

Here we'll need to do     case " $GLOBAL_CONFIG_VARIABLES "...

> +                               *" ${LINE%=*} "*) continue ;;

... otherwise this will not match for the first GLOBAL_CONFIG-variable.

> +                               *) eval $LINE ;;
> +                       esac
> +               done < $cfg
>         done
>  }

Other than that, fine with me (if it works, i did not test it :-))
-- 
Stefan Seyfried
QA / R&D Team Mobile Devices        |              "Any ideas, John?"
SUSE LINUX Products GmbH, Nürnberg  | "Well, surrounding them's out." 


More information about the Pm-utils mailing list