tech-userlevel archive

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

Re: rc.subr: Passing extra arguments to run_rc_command



On Fri, 12 Mar 2010, Julio Merino wrote:
> Therefore, I'd like to modify run_rc_command to take a set of optional
> extra arguments that will later be fed to the _precmd, _cmd and
> _postcmd functions.  See the attached patch.
> 
> Any objections or comments?

Is it worth annotating the commands to say whether or not they take
extra args, and giving an error when args are passed to a command that
does not take them?  I am thinking along these lines:

        # grep extra_commands /etc/rc.d/myscript
        extra_commands="foo bar*"
        # /etc/rc.d/myscript blah
        /etc/rc.d/myscript: unknown directive 'blah'.
        [above error message is from run_rc_command in rc.subr]
        # /etc/rc.d/myscript foo
        [works]
        # /etc/rc.d/myscript foo arg
        /etc/rc.d/myscript: directive 'foo' does not take arguments.
        [above error message is from run_rc_command in rc.subr]
        # /etc/rc.d/myscript start arg
        /etc/rc.d/myscript: directive 'start' does not take arguments.
        [above error message is from run_rc_command in rc.subr]
        # /etc/rc.d/myscript bar
        [works, or not, according to how the script was written]
        # /etc/rc.d/myscript bar arg
        [works, or not, according to how the script was written]

--apb (Alan Barrett)


Home | Main Index | Thread Index | Old Index