hercules-team / augeas

A configuration editing tool and API
http://augeas.net/
GNU Lesser General Public License v2.1
487 stars 199 forks source link

properties lens does not support empty comments #370

Open jgeraerts opened 8 years ago

jgeraerts commented 8 years ago

The properties lens fails on a property file containing a single # character.

#
# this is doing good while the above fails
foo=bar
raphink commented 8 years ago

Just added 6f680e5 with a test which shows that it works.

raphink commented 8 years ago

Which version of Augeas are you using?

jgeraerts commented 8 years ago

It is 1.2.0 (standard trusty package). I did some extra tests and i think it is due to the '\r' in my file cause it was edited on windows.

# augtool -At "Properties incl /tmp/test.properties"
augtool> print /augeas/files/tmp/test.properties/error
/augeas/files/tmp/test.properties/error = "parse_failed"
/augeas/files/tmp/test.properties/error/pos = "132"
/augeas/files/tmp/test.properties/error/line = "5"
/augeas/files/tmp/test.properties/error/char = "0"
/augeas/files/tmp/test.properties/error/lens = "/usr/share/augeas/lenses/dist/properties.aug:50.25-.100:"
/augeas/files/tmp/test.properties/error/message = "Iterated lens matched less than it should"

The failing properties file is attached. I 'll try to upgrade to the master version and see if i can reproduce it with master.

test.zip

jgeraerts commented 8 years ago

the master branch exhibits the same issue

$ ./augtool -I ../lenses/ -At "Properties incl /tmp/test.properties"
augtool> print /augeas/
context    files/     load/      root       save       span       variables  version/
augtool> print /augeas/files/tmp/test.properties/error/
/augeas/files/tmp/test.properties/error = "parse_failed"
/augeas/files/tmp/test.properties/error/pos = "133"
/augeas/files/tmp/test.properties/error/line = "5"
/augeas/files/tmp/test.properties/error/char = "1"
/augeas/files/tmp/test.properties/error/lens = "../lenses/properties.aug:50.25-.100:"
/augeas/files/tmp/test.properties/error/lens/last_matched = "../lenses/util.aug:139.6-.14:"
/augeas/files/tmp/test.properties/error/lens/next_not_matched = "../lenses/util.aug:22.27-.34:"
/augeas/files/tmp/test.properties/error/message = "Iterated lens matched less than it should"
raphink commented 8 years ago

OK, that's more likely. Let's add a test for that and fix it with Util.dos_eol and friends

jgeraerts commented 8 years ago

Would that support files with mixed-lineends as well? I've seen those in the wild too.

raphink commented 8 years ago

Yes