> -----Original Message-----
> From: David Chisnall [mailto:thera...@freebsd.org]
> Sent: Sunday, February 23, 2014 10:18 AM
> To: Allan Jude
> Cc: FreeBSD Current
> Subject: Re: libinit idea
> On 23 Feb 2014, at 18:11, Allan Jude <free...@allanjude.com> wrote:
> > sysrc solves this nicely, it is in base now, and is great for
> > programmatically adding, removing and changing lines in rc.conf style
> > files. It is also in ports for older versions of FreeBSD where it is
> > not in base.
> The problem is, there is no such thing as an rc.conf style file. rc.conf
is just a
> shell script. If you only edit it with sysrc, or you are careful to
> structure, then it's fine.
Actually, sysrc is well aware that rc.conf is a shell script and sysrc will
make certain that structure is preserved (regardless of whether you've
shell code in rc.conf or not).
> There is absolutely nothing stopping you, however,
> from writing arbitrarily complex shell scripts inside rc.conf. Sure, it's
> idea to do so, but when has that ever stopped anyone?
When sysrc is told to make a change, it first finds where it needs to make
change (/etc/rc.conf or /etc/rc.conf.local or one of other paths mentioned
rc_conf_files setting), it will refuse to edit the file *IF* the file
(before editing) pass a shell syntax check (using "sh -n FILE"). After
changes in a temporarily file (produced with mktemp(1)), it again performs
another syntax check (also using "sh -n FILE") to make sure that it
yield clean syntax.
On top of that, it makes certain not to muck with dynamic assignments. So it
will leave-alone an assignment such as "foo=$( bar )" if told to edit the
foo -- instead opting to add a foo=newvalue after the dynamic assignment
is simple... sysrc wasn't responsible for putting that dynamic assignment
it is going to leave it as-is and put the new [static] assignment further
So Allan was absolutely correct in stating that sysrc is for editing
files -- shell scripts really. In essence, sysrc is actually a shell script
utility that takes extreme special care to rely on the fact that rc.conf
> An rc-replacement could enforce this by only accepting purely declarative
> for configuration, guaranteeing that if they were syntactically valid they
> also be machine editable, no matter what the user does to them.
sysrc does this for you.
The information contained in this message is proprietary and/or confidential.
If you are not the intended recipient, please: (i) delete the message and all
copies; (ii) do not disclose, distribute or use the message in any manner; and
(iii) notify the sender immediately. In addition, please be aware that any
message addressed to our domain is subject to archiving and review by persons
other than the intended recipient. Thank you.
email@example.com mailing list
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"