On Mon 2000-04-10 (00:10), Doug Barton wrote:
> +if [ -z "${sourcercs_defined}" ]; then
> +        sourcercs_defined=yes
> +        sourcercs ( ) {
> +                local sourced_files
> +                for i in ${rc_conf_files}; do
> +                        case "${sourced_files}" in
> +                        *:$i:*)
> +                                ;;
> +                        *)
> +                                sourced_files="${sourced_files}:$i:"
> +                                if [ -r $i ]; then
> +                                        . $i
> +                                fi
> +                                ;;
> +                        esac
> +                done
> +        }
> +fi

I have another idea:  We make a sh script named "rcsource" or whatever,
which we source when we want to have the rc environment, stealing your
code maliciously:

/--
sourcercs_sourced_files=
sourcercs ( ) {
        local rc_conf_files
        for i in $*; do
                case "${sourcercs_sourced_files}" in
                *:$i:*)
                        ;;
                *)
                        sourcercs_sourced_files="${sourcercs_sourced_files}:$i:"
                        echo $i
                        if [ -r $i ]; then
                                . $i
                                sourcercs ${rc_conf_files}
                        fi
                        ;;
                esac
        done
}
sourcercs /etc/defaults/rc.conf
\--

Anyway, this'll do something I've been considering missing - the ability
to set more rc_conf_files in /etc/rc.conf and friends.  It also means a
total lack of sh-script in /etc/defaults/rc.conf and /etc/rc.conf, which
means that we can start developing something in C that can read those
files (libconf, Daniel?).

Basically, it localizes rc_conf_files so that you don't lose any you've
specified before.  So, in /etc/defaults/rc.conf, it sets rc_conf_files
to "/etc/rc.conf /etc/rc.conf.local", and when it runs /etc/rc.conf,
rc_conf_files changes to "/etc/foo.conf", and that'll be read.  After
it's finished, it pops up two spaces, and goes on to /etc/rc.conf.local.

A file will only ever be sourced once.

One possible extension may be a specifier of a preprocessor for a file:

preprocessor__etc_defaults_rc.conf='cpp' will be checked if sourcercs is
run on /etc/defaults/rc.conf, and it will be passed through cpp before
trying to understand it.  This should be extensible enough to avoid the
need of sh-script to get a value for a variable.

Any more ideas?

Neil
-- 
Neil Blakey-Milner
Hacker In Chief, Sunesi Clinical Systems
[EMAIL PROTECTED]


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to