tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: rc.d/rndctl

On Thu, 18 Sep 2008, Brian A. Seklecki wrote:
> > Please allow for control over which devices get "-c -e" and which get
> > "-c" without "-e".  Please also allow for use of the "-d" flag instead
> > of only "-t".
> Right -- but no way to iterate or parse through semicolon separated
> lists,

What do you mean?  What's wrong with

        IFS=';' eval set -- \$rndctl_flags


Here's a more complete suggestion:

        # Split on semicolons
        IFS=';' eval set -- \$rndctl_flags
        for args in "$@"; do
                # Within a single semicolon-separated segment,
                # parse zero or more flags followed by one or more devices.
                ceflags=''      # one or more of -c/-e/-C/-E
                dtflags=''      # exactly one of -d/-t
                for arg in $args; do
                        case "$arg" in
                                ceflags="${ceflags}${ceflags:+ }${arg}"
                                dtflags="${dtflags}${dtflags:+ }${arg}"
                                # Perform the command with the specified
                                # device or type name.
                                # ceflags defaults to "-c -e".
                                # dtflags defaults to "-d".
                                : ${ceflags:=-c -e}
                                : ${dtflags:=-t}
                                $command ${ceflags} ${dtflags} ${dev}

--apb (Alan Barrett)

Home | Main Index | Thread Index | Old Index