[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [augeas-devel] Less-stuffed interfaces lens



On Mon, 2009-05-11 at 14:05 +1000, Matt Palmer wrote:
> Solved my earlier problem of not being able to write a simple
> /etc/network/interfaces file, by fixing the lens.

As you've discovered, the interfaces lens needs a bit of work.

> I also went and fixed the
> lens for several incompatibilities with the file format specification, made
> generic allow-* work, and wrote a test to make sure that the lens can
> actually write something.

Cool .. thanks for doing that.

> I've attached both the lens and it's test spec, since it's a bit much to
> paste.

A couple of questions:

> diff --git a/lenses/interfaces.aug b/lenses/interfaces.aug
> index 98389e8..c437fe2 100644
> --- a/lenses/interfaces.aug
> +++ b/lenses/interfaces.aug
> @@ -17,12 +17,12 @@ let eol        = Util.eol
> (* Define separators *)
> 
> (* a line can be extended across multiple lines by making the last  *)
> -(*  character a backslash, unless the line is a comment (see below)
> *)
> +(*  character a backslash *)
> let sep_spc    =  del /([ \t]+|[ \t]*\\\\\n[ \t]*)/ " "
> 
> (* Define fields *)
> -let sto_to_eol = store /([^\\# \t\n].*[^\\ \t\n]|[^\\ \t\n])/
> -let sto_to_spc = store /[^\\# \t\n]+/
> +let sto_to_eol = store /([^\\ \t\n].*[^\\ \t\n]|[^\\ \t\n])/ . eol
> +let sto_to_spc = store /[^\\ \t\n]+/

The '#' character was not allowed there because it starts a comment; is
that not true in all cases ?

> let mapping = [ stanza_id "mapping"
> -               . (comment|empty)+
> -               . stanza_option
> -               . (stanza_option|comment|empty)* ]
> +               . eol
> +               . (stanza_option|comment|empty)+ ]

Doesn't this disallow 'mapping # my favorite mapping\n...' ? I am far
from an expert on interfaces syntax, but isn't that a legal line ?

> (************************************************************************
>   *                              IFACE
> @@ -76,8 +77,8 @@ let mapping = [ stanza_id "mapping"
> let iface   = [ stanza_id    "iface"
>                . stanza_param "family"
>                . stanza_param "method"
> -              . (comment|empty)+
> -              . ( stanza_option . (stanza_option|comment|empty)* )? ]
> +              . eol
> +              . (stanza_option|comment|empty)* ]

This seems to disallow end-of-line comments here, too.

> diff --git a/lenses/tests/test_interfaces.aug
> b/lenses/tests/test_interfaces.aug
> index 62bbd20..9495b4a 100644
> --- a/lenses/tests/test_interfaces.aug
> +++ b/lenses/tests/test_interfaces.aug
> @@ -4,13 +4,13 @@ module Test_interfaces =
> # and how to activate them. For more information, see interfaces(5).
> # The loopback network interface
> 
> -auto lo eth0 # Take me to the net
> +auto lo eth0 #foo

I am now getting very confused with what are comments in the interfaces
file vs. valid entries ... /me goes to read the man page.

David



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]