[augeas-devel] Re: Prefix for IniFile entries

Raphaël Pinson raphink at gmail.com
Wed Aug 27 08:57:15 UTC 2008


On Wed, Aug 27, 2008 at 10:49 AM, Free Ekanayaka <free at 64studio.com> wrote:

> Hi Raphaël,
>
> |--==> On Tue, 26 Aug 2008 21:19:51 +0200, "Raphaël Pinson" <
> raphink at gmail.com> said:
>
>  RP> On Tue, Aug 26, 2008 at 7:23 PM, Free Ekanayaka <free at 64studio.com>
> wrote:
>  >>Hi,
>  >>
>  >>the /etc/samba/smb.conf is basically a INI file, but it allows entries
>  >>to be prefixed by spaces and tabs, like:
>  >>
>  >>[global]
>  >>
>  >># Change this to the workgroup/NT-domain name your Samba server will
> part
>  >>of
>  >>workgroup = WORKGROUP
>  >>
>  >>Is there are way to set this as a parameter in inifile.aug?
>  >>
>
>   RP> I have considered adding indentation support to inifile.aug but it
> does not
>  RP> seem to be standard INI file syntax, and adding it optionally would
> make the
>  RP> interface heavier.
>
>
>  >>
>  >>I've tried to define an entry as:
>  >>
>  >>let entry = del / */ "" . IniFile.entry setting sep comment
>  >>
>
>   RP> You could probably use Util.indent instead of this.
>
> I've tried some more combinations and discovered that if I prepend del / */
> ""
> or Util.indent to the entry definition in samba.aug, then I get:
>
> lenses/samba.aug:28.13-.60:exception: ambiguous concatenation
>      ' #A\n' can be split into
>      '|=| #A\n'
>
>     and
>      ' |=|#A\n'
>
>    First lens: lenses/util.aug:12.15-.30
>    Second lens: lenses/inifile.aug:47.25-.85
>
> but if I prepend it in the entry definition of inifile.aug:
>
> diff -r 6b66d3426ef2 lenses/inifile.aug
> --- a/lenses/inifile.aug        Tue Aug 26 01:59:55 2008 +0200
> +++ b/lenses/inifile.aug        Wed Aug 27 10:45:47 2008 +0200
> @@ -44,7 +44,7 @@ let comment_default    = ";"
>  (* entry includes comments *)
>
>  let entry (kw:regexp) (sep:lens) (comment:lens)
> -                       = [ key kw . sep . sto_to_comment? . (comment|eol)
> ] | comment
> +                       = [ Util.indent . key kw . sep . sto_to_comment? .
> (comment|eol) ] | comment
>  let entry_re           = ( /[A-Za-z][A-Za-z0-9\._-]+/ - /#comment/ )
>
>
> then everything runs smoothly. I don't understand exactly why..
>


I've had the same kind of issue with 'empty'. When I don't use [] brackets,
it fails and I don't understand why.



>
> I've run the puppet dput and php tests, and it turns out that
> prepending Util.ident does not seem to break any of the. So I wonder
> if it would be possible to include this change in inifile.aug.
>


Yes, it doesn't break anything, but it doesn't typecheck either. That said,
Util.indent defaults to "", which means that it's impossible to add an
explicit indentation from augeas, and manual indentation in the conffile
should not have been added unless it's supported by the format.

If it was added to inifile.aug, it would have to be added to all kinds of
entries though.


Ciao


Raphaël
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20080827/226acba3/attachment.htm>


More information about the augeas-devel mailing list