tech-userlevel archive

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

Re: config file formats



On Wed, Jul 20, 2011 at 12:03:22PM +0200, Marc Balmer wrote:
 > I just have a technical comment:
 > 
 > I guess this assumes that lines starting with '#' are considered
 > comments, but that is not true in all cases.

Not entirely; it is convenient for the header to be a comment but not
particularly necessary. Making it a comment just saves the config
parser the trouble of skipping over it explicity.

 > E.g. I have some config files that are actually Lua programs, and there
 > a comment is '--' (like in SQL) and other formats, like BIND zone files
 > use a semicolon.
 > 
 > Maybe the format specifier should appear somewehre on the first line,
 > then a construct like
 > 
 > -- #@syslogd 2012
 > 
 > would work as well.

I don't think that's a great idea (although if it is, the -*- foo -*-
syntax from emacs is another candidate) because ideally the code that
reads the header should be simple.

That is, like with exec, what you really want in general is

   read(fd, buf);
   if (!memcmp(buf, MAGIC_0)) format_0(fd);
   else if (!memcmp(buf, MAGIC_1)) format_1(fd);
   else if (!memcmp(buf, MAGIC_2)) format_2(fd);
   ...

with as little fuss as possible. Granted we probably don't want to be
doing major revisions of config file formats in /etc very often so
there shouldn't be many cases.

Anyway, I'm not sure I particularly like any of the proposed spellings
so far (including my own suggestion) but I'm glad to see nobody is
drastically against the idea. We can defer the choice of spelling
until I or someone has a real patch set ready; and maybe by then after
keeping the issue in the backs of our minds for a while it'll become
clearer.

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index