augeas icon indicating copy to clipboard operation
augeas copied to clipboard

simplevars.aug does not support updating of values which were previously empty

Open akissa opened this issue 8 years ago • 7 comments

Sample data:

PROXY_HOSTS =

set /files/etc/macros.conf/PROXY_HOSTS "192.168.1.10"

Error produced

Value '192.168.1.10' does not match regexp // in store lens

akissa avatar Apr 08 '16 10:04 akissa

This is unfortunately hard to fix while avoiding ambiguities. The current code reads:

let entry =
     let some_value = Sep.space_equal . store to_comment_re
     (* Avoid ambiguity in tree by making a subtree here *)
  in let empty_value = [del /[ \t]*=/ "="] . store ""
  in [ Util.indent . key Rx.word
            . (some_value? | empty_value)
            . (Util.eol | Util.comment_eol) ]

which prevents the node from being changed from empty_value to some_value?.

let entry =
     let some_value = Sep.space_equal . store to_comment_re?
  in [ Util.indent . key Rx.word
            . some_value?
            . (Util.eol | Util.comment_eol) ]

would not work because it creates an ambiguity when there is a space after the = and no value (and there could be a space at the eol).

let entry =
     let some_value = del /[ \t]*=/ "=" . store to_comment_re?
  in [ Util.indent . key Rx.word
            . some_value?
            . (Util.eol | Util.comment_eol) ]

fixes the current issue, but prevents from parsing values that start with a space.

I currently don't see a way to fix that. @lutter any ideas?

raphink avatar Apr 13 '16 09:04 raphink

The difficulty here is that we have to distinguish between three different kinds of lines:

key=value
key=
key

If people should be able to go from one of those lines to the other by simply setting the value, we need to do that without any additional helper nodes, like the one that empty_value currently produces. The whole thing would neatly map to the three trees

{ "key" = "value" }
{ "key" = "" }
{ "key" }

except that the typechecker currently does not distinguish between nodes with a NULL value and nodes with the empty string as a value. I'll try to put up a PR for that, though it requires that people become much more careful about whether they say something like set /foo "" or clear /foo. With the way the code is currently, the two are interchangeable; after the change they will be viewed as different.

lutter avatar Apr 26 '16 00:04 lutter

@lutter that would be very useful. There are various format where a difference between empty value and no value would make sense.

raphink avatar Apr 26 '16 06:04 raphink

I've put the my work onto this branch: https://github.com/lutter/augeas/tree/dev/node-null-value

The actual code change is two lines in lens.h; the big problem is that it makes lots of tests fail. I've fixed up some of them, but others I am not sure yet if the failure is caused by a lens that improperly assumes a NULL node value and an empty string as a node value are the same, or if there are other places in the code that need fixing up. Would love any help I can get with this; just fixing the obvious test failures would be helpful, particularly for lenses you know well.

lutter avatar Apr 26 '16 16:04 lutter

I can try to throw an eye, probably not soon though.

raphink avatar Apr 26 '16 16:04 raphink

Any traction on this ? I just discovered that you cannot set a key to blank in inifile as well. For real world usage this is such a limiting factor.

akissa avatar Jul 04 '17 06:07 akissa

Hi, any chance that this issue is fixed one day? This prevents to update BeeGFS config files.

ysagon avatar Aug 19 '22 12:08 ysagon