Mail archive

[Acf] lib/getopts.lua

From: Mika Havela <>
Date: Thu, 8 May 2008 13:05:38 +0200

Good morning.
I'm writing some notes while looking through ACF and the previous updates.
I guess it's "work in progress" so the ones working with it have most
likely a plan to solve the problems and you probably already know of
the existing bugs.
But I write them here just to be sure that they don't get missed.

Previously we got a change in 'lib/getopts.lua'. I admit (being the
one creating it from the beginning) that the original code was not
that clean/good but it was a way to get things working. So updating it
is highly appreciated.
I made things a bit complicated because I used same function to parse
a config-file-line that could look like "MYVARIABLE=myvalue" (this
would result in a table that looked like {['MYVARIABLE']='myvalue'}
but in the same time the config-file-line could look like
"MYVARIABLES='-a -b 1 -c -d 2' (this would result in something that
looked like {['MYVARIABLES']={['-a']='', ['-b']='1', ['-c']='',
['-d']='2'} }.
I /think/ that the getopts.lua was created while working with
alpine-baselayout/syslog-model.lua. The config-file for syslogd had
the more complicated type of config-file objects. But in most cases a
config-file just has lines that looks like " MYVARIABLE='myvalue' "
(With or without citation marks around the value). But as I
mentioned... the library was built to solve the problem with the more
complicated type of config-file-values.
Maybe it would be better to have separate functions that reads these
different type of config-file-rows.
Now you got some history about when/why this library was built in the
first place.
Because I don't know what's the plans for this library (you probably
have some thought what to do with it) then I don't fix the errors
caused by the modifications in this library... I just note them here,
so you easily find the errors and can fix them (ether by modifying the
lib/getopts.lua or modifying the file that calls for lib/getopts.lua -
It's your choice).

Used getopts to read config-files that looked like this:
  $ cat /etc/conf.d/syslog
  SYSLOGD_OPTS="-s 1000 -m -O /var/log/messages -l 8 -b 99"
This information is then used to figure out what/how to display data
for the user, and in some cases this information is used to display a
wrong configuration.
EXAMPLE: By using revision1110. Change "-l 8" to "-l 9". (This will
trigger a error and display a warning because syslogd doesn't accept
values grater than 8)
CURRENT STATUS: The model doesn't get values from /etc/conf.d/syslog

As I can see... so far it's only acf-alpine-baselayout(syslog) module
that uses lib/getopts.lua and has a config-file that looks like
described above, so It's only there I found that something is broken.
But in the future I think we will have use of a function that reads
this type of complicated config-file-values.


To Nathan:
Could you see to that ttrask gets this mail (he's not subscribed to and I don't have hes contacts)
Received on Thu May 08 2008 - 13:05:38 UTC