Date: Mon, 5 Mar 2007 22:31:25 +0300 From: Yar Tikhiy <yar@comp.chem.msu.su> To: Doug Barton <dougb@FreeBSD.org> Cc: freebsd-rc@FreeBSD.org Subject: Re: cvs commit: doc/en_US.ISO8859-1/articles/rc-scripting article.sgml Message-ID: <20070305193125.GG57253@comp.chem.msu.su> In-Reply-To: <45EB4DC1.6040903@FreeBSD.org> References: <200703031011.l23ABYhb039755@repoman.freebsd.org> <45EA68AF.6000700@FreeBSD.org> <20070304130408.GJ40430@comp.chem.msu.su> <45EB4DC1.6040903@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Mar 04, 2007 at 02:52:49PM -0800, Doug Barton wrote: > Yar Tikhiy wrote: > >On Sat, Mar 03, 2007 at 10:35:27PM -0800, Doug Barton wrote: > >>Yar Tikhiy wrote: > >>>yar 2007-03-03 10:11:34 UTC > >>> > >>> FreeBSD doc repository > >>> > >>> Modified files: > >>> en_US.ISO8859-1/articles/rc-scripting article.sgml > >>> Log: > >>> Explain how an rc.d script can use extra command-line arguments. > >>> > >>> Revision Changes Path > >>> 1.9 +138 -0 > >>> doc/en_US.ISO8859-1/articles/rc-scripting/article.sgml > >>> > >>>http://www.FreeBSD.org/cgi/cvsweb.cgi/doc/en_US.ISO8859-1/articles/rc-scripting/article.sgml.diff?&r1=1.8&r2=1.9&f=h > >>Yar, > >> > >>This good stuff, thanks! I have one quibble with the last paragraph. > >>The shift in rc.subr isn't "apparent" as you phrase it, it's literal: > > > >Yeah, I tried to hide a thing from the reader which he should already > >have known: the shift command. :-) > > Again, looking at it from the point of view of a naive reader, there > is a difference between "I know that the shift command exists, and > sort of know what it does" and "I know how the shift command is used > by rc.subr to affect the command line arguments to my script." Your > article is (to some extent) about teaching the latter, so I think it's > reasonable to spend some time spoon feeding the reader until they are > ready for some meat. Agreed! The new revision tries to do that better. > >>run_rc_command() > >>{ > >> ... > >> # Don't repeat the first argument when passing additional command- > >> # line arguments to the command subroutines. > >> # > >> shift 1 > >> rc_extra_args="$*" > > > >Oh my... Now I see why existing rc.d scripts use this bogus command: > > > > run_rc_command "$*" > > > >It's because rc.subr will mess up the arguments anyway. > > I think it's more likely that someone would use $* vs. $@ out of force > of habit. :) It's a bad habit IMHO unless one really means $* :-) > >Perhaps > >we should investigate if "$@" can be used consistently to preserve > >original boundaries between arguments to an rc.d script... > > I wouldn't object to some testing on that. I'll change my local copy > and see how it behaves. I took a look at that and found that, as long as we support for random shell expressions in $foo_cmd, the magic wand of "$@" cannot help us without some additional black magic. If $foo_cmd were guaranteed to be merely the name of a function or simple command, then we would need no final eval to execute $foo_cmd. But stuffing shell expressions in $foo_cmd is neat and should be supported. Perhaps we should just tell people that they cannot pass hairy arguments to rc.d scripts -- each argument must be a simple word. -- Yar
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070305193125.GG57253>