sysrc(8) and non valid shell script variable names

So, as I understand it, valid shell script variable names are [0-9ABC...Zabc...z_]--also listed in /usr/share/bsdconfig/sysrc.subr-. When I use `sysrc(8)` on my rc.conf file, everything is great but I cannot use `sysrc(8)` on jail.conf because that file has "non-valid" variable names.

EX: host.hostname = "${name}";

I noticed that in the `sysctl(8)` this dotted style is refered to as: "Management Information Base" ("MIB") style. Is there anything like `sysrc(8)` that can work with 'MIB' style variable names in other files (like jail.conf)?
 
Just for follow up / conversation.
I followed links and read up on `uclcmd`, `libucl` and etc. but I also tugged on this concept/idea thread a bit more and built some concept code to GET vars (in C) from different config styles.

My test conf file has entries like:

Code:
name1   =       value1
name2   =       value2;                         # comment.
#name3  =       value3                          # comment.

/**
 * name4 =  value4
 */

name5   =       "value5";
name6           value6 value6a value6b          # comment.
name.7  =       value.7;

So far, I can tokenize the names/values from these conditions (not the commented-out ones, of course) and probably a few more conditions. Current state of my mockup is just a tokenizer and/so, retrieval can get the "value" or "value and comment". I imagine that PUTTING will be more difficult, but the mockup GET works on /etc/rc.conf, /etc/jail.conf and /etc/sysctl.conf.

1. Don't know what to call the tool (mock-up). Currently called `confget`.
2. Syntax is: `./confget -c -f file var` (-c means to show the comment token, omit for just the value).
3. Very much NOT able to read ucl, json, xml, etc., this is only just a simple name=var type tokenizer (value getter).
4. This probably could have been done in shell script in a few lines but, this was a fun thing to do (and I got a few cool functions out of the exercise).
 
I was thinking about this topic more and I decided to play a bit more with this idea. First though, "confget" is a stupid name so 'sysconf' is what I'm going to call my toy for this post.

My thoughts were about how there are several different tools depending on different syntaxes/files and how each have different command flags.

I was thinking a program like this should be able to discern, based on the arguments given, what to do. For example:

Code:
% sysconf -f /etc/rc.conf
Just show the keys and values in the file.

% sysconf -f /etc/rc.conf key
Just show me the value for the given key.

% sysconf -f /etc/rc.conf key=value
Add or make a change.

% sysconf -f /etc/rc.conf key+=value2
Make an addition.

After a bit of playing around, I have a thing that can work as above for different "key/value" type configuration syntaxes (nothing too complicated). My new tool detects if the line is (and makes the appropriate change):

Code:
key = value value2;
key=vale
key="value";
key value
key : value
key:"value"
...

My toy will also only write a key/value if the value is different and/or only once.

For example, given "file.conf":
key=value
Code:
% sysconf -f /file.conf key=value
Doesn't make a change.

% sysconf -f /file.conf key=newvalue
Makes a change

I wrote this tool not using any dependencies so there is nothing to break if/when something is/isn't updated (-i.e., should "just work" on simple key/value configuration files or something that resembles a simple key/value entry no matter what language it's typed in).

My question is:
Does this sound at all interesting? -i.e., should I keep going with this or just plan to keep this for myself?
 
Yes, quite interesting. I would love to see your utility become part of FreeBSD. Also of note, Devin Teske has been threatening to release a utility named sysconf that does this for many many years. See also, 'man figpar'
 
Yes, quite interesting. I would love to see your utility become part of FreeBSD. Also of note, Devin Teske has been threatening to release a utility named sysconf that does this for many many years. See also, 'man figpar'
You got it. :) I pushed my code to GitHub as well a few weeks ago. It's not in ports tree but I was talking with vermaden and he nudged me to get working on that. However, `make`, `make install`, `man sysconf`, and all the other typical stuff should work as expected.

Sorry, I do not know who Devin Teske is but I'm fairly confident in saying that anything he would (or virtually most people would) provide I'm sure would put my feeble attempt to shame.

Oh that `figpar` looks very interesting! I wish I knew about that before I started on my tool because I rolled my own "mini parser" but that's part of the initial objectives behind writing mine (zero dependencies).

Below is the link to the GitHub repo; please break it (and please let me know if it works for you):
 
> would put my feeble attempt to shame.

It will hardly matter if yours works and ships. Great ideas have little value until they ship, and a mediocre attempt that ships and works aces a perfect idea that hasn't.
 
Back
Top